besoin d'un pro vb car je galere

besoin d'un pro vb car je galere - VB/VBA/VBS - Programmation

Marsh Posté le 09-01-2006 à 15:19:14    

bonjour a tous je susi en train de creer un script d'ouverture de session. mais ne connaisant pas vbs je lutte. Je cherhce comment faire pour faire un if sur le nom du user c est a dire :
 
if le user s appelle admin faire
xxxxxx
 
sinon faire
xxxx
 
comment je peux traduire ca en vbs sil vous plait ?

Reply

Marsh Posté le 09-01-2006 à 15:19:14   

Reply

Marsh Posté le 09-01-2006 à 15:21:38    

if user="admin" then
 
else
 
end if


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 15:25:07    

ya que ca a faire ? et dans le sinon il prend en compte tous les autres utilisateurs  ?

Reply

Marsh Posté le 09-01-2006 à 15:39:51    

oui


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 15:49:26    

ok merci de ta reponse
 
j aurais maintenant une 2e question. comment je peux faire pour recuperer dans le script le nom du poste qui se connecte et etudier les deux 1eres lettres ?
 
merci de ton aide

Reply

Marsh Posté le 09-01-2006 à 16:36:58    

Dim oWshNetwork
Dim sNomOrdinateur
Set oWshNetwork = CreateObject("WScript.Network" )
sNomOrdinateur = oWshNetwork.ComputerName  


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 16:42:35    

merci
 
donc avec ca je recupere le nom du poste. et est ce que je n'ai plus qu a faire un :
 
mid(%computername%,1,1)=S pour etudier la 2e lettre et voir si c'est un S ?
 
merci de ta reponse

Reply

Marsh Posté le 09-01-2006 à 16:48:21    

ça me semble bon


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 16:52:55    

j'ai fini mon script mais je ne suis pas sur de moi
 
est ce que je peux le poster afin que tu y regarde ?

Reply

Marsh Posté le 09-01-2006 à 17:03:02    

vas-y, pas de problème :)


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 17:03:02   

Reply

Marsh Posté le 09-01-2006 à 17:09:59    

Script
 
 
 
   
If user = admin  Then
      Dim net
             Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS3"
net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS4"
net.AddWindowsPrinterConnection "\\dirennantes\hydrohp3200"
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL2"
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL5"
net.AddWindowsPrinterConnection "\\dirennantes\LXC912PCLSEMA"
net.AddWindowsPrinterConnection "\\dirennantes\LXW820PCLSEMA"
 
 
Else  
     
 
 Dim strComputerName  
Dim WshShellObj  
Dim WshProcessEnv  
Dim WshComputername  
 
 
Set WshShellObj = WScript.CreateObject("WScript.Shell" )  
Set WshProcessEnv = WshShellObj.Environment("PROCESS" )  
WshComputername = GetComputerName  
 
   
 
 
Private Function GetComputerName()  
Dim oNetwork  
     
   On Error Resume Next  
   Set oNetwork = CreateObject("WScript.Network" )  
   GetComputerName = oNetwork.ComputerName  
   Set oNetwork = Nothing  
End Function
 
 
                                    IF  
 
(Mid(%computerName%, 1, 1) = S then
 
 
                           Dim net
                               Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection "\\dirennantes\LXC912PCLSEMA"
net.AddWindowsPrinterConnection «\\dirennantes\LXW820PCLSEMA»
 
                         Else IF
 
(Mid(%computerName%, 1, 1) = H then
 
        Dim net
Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection \\dirennantes\hydrohp3200
net.AddWindowsPrinterConnection "\\dirennantes\faxhydro"
           
                         Else IF
 
(Mid(%computerName%, 0, 1) = P then
 
            Dim net
Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS3"
net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS4"
net.AddWindowsPrinterConnection "\\dirennantes\hydrohp3200"
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL2"
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL5"
net.AddWindowsPrinterConnection "\\dirennantes\LXC912PCLSEMA"
net.AddWindowsPrinterConnection "\\dirennantes\LXW820PCLSEMA"
 
 
Else If
 
(Mid(%computerName%, 0, 1) = S then
 
      Dim net
Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS3"
net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS4"
net.AddWindowsPrinterConnection "\\dirennantes\hydrohp3200"
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL2"
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL5"
net.AddWindowsPrinterConnection "\\dirennantes\LXC912PCLSEMA"
net.AddWindowsPrinterConnection "\\dirennantes\LXW820PCLSEMA"
 
 
 
else if
 
(Mid(%computerName%, 1, 2) = M2 then
           
 
        Dim net
Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection "\\dirennantes\LXC910PCL2"
     net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS3"
 
                      Else if
 
(Mid(%computerName%, 1, 2) = M3 then
           
 
        Dim net
Set net= CreateObject("WScript.Network" )
             net.AddWindowsPrinterConnection \\dirennantes\IR3100CPS4
     net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS3"
             
 
Else if
 
(Mid(%computerName%, 1, 2) = M4 then
 
        Dim net
Set net= CreateObject("WScript.Network" )
 
               net.AddWindowsPrinterConnection \\dirennantes\IR3100CPS4
             net.AddWindowsPrinterConnection "\\dirennantes\IR3100CPS3"
 
Else if
 
(Mid(%computerName%, 1, 2) = M5 then
 
        Dim net
Set net= CreateObject("WScript.Network" )
net.AddWindowsPrinterConnection \\dirennantes\IR3100CPS4
     net.AddWindowsPrinterConnection \\dirennantes\LXC910PCL5
 
 
End if
 
End

Reply

Marsh Posté le 09-01-2006 à 17:19:32    

heuuuu c'est pas super lisible [:le kneu]


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 17:22:59    

Pour récupérer le nom de l'utilisateur, il faut faire  
Dim oWshNetwork  
Dim sNomUtilisateur  
Set oWshNetwork = CreateObject("WScript.Network" )  
sNomUtilisateur = oWshNetwork.UserName  
 
 
 
Et plutot que de faire un CreateObject("WScript.Network" ) dans chaque else de ton script, fais le une fois au début de ton script et réutilise le par la suite


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 17:30:50    

pour le nom de l'utilisateur, faut que je place tes lignes au debut du script ?

Reply

Marsh Posté le 09-01-2006 à 17:33:45    

ben oui vu que tu t'en sers dès le début


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 17:35:39    

ok en tout cas je te remercie pour tout

Reply

Marsh Posté le 09-01-2006 à 17:42:06    

de rien. ;)
 
Teste ton script quand même parce qu'il m'a l'air un peu ... brouillon


---------------
"I wonder if the internal negative pressure in self pumping toothpaste tubes is adjusted for different market altitudes." John Carmack
Reply

Marsh Posté le 09-01-2006 à 17:47:36    

oué je le testerai demain et jte redirais

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed