Script de connexion

remirom -  
globalscript Messages postés 14 Statut Membre -
Bonjour,

voila j'ai fait un script de connexions, c'est pas du tout ma specialite

j' rencontre des erreurs régulièrement, pouvez m'aider et me proposer des solutions plus simlple,

en fait le script permet de mettre en place des icones et des acces reseaux et imprimantes en fonction de son groupe d'organisation dans l'ad

merci d'avance pour votre aide

voici le code:

Option Explicit
Dim groupe, util, res, chemin, dico, strmap, fso
set res = CreateObject("Wscript.network")
Set fso = CreateObject("Scripting.FileSystemObject")

Function IsMember(sGroup)
Dim sAdsPath,oUser,oGroup,g_oGroupDict,g_oNet
'Peupler dictionnaire si pas encore créé
If IsEmpty(g_oGroupDict) Then
Set g_oGroupDict=CreateObject("Scripting.Dictionary")
g_oGroupDict.CompareMode = vbTextCompare
sAdsPath = res.UserDomain &"/"& res.UserName
Set oUser = GetObject("WinNT://"& sAdsPath & ",user")
For Each oGroup In oUser.Groups
g_oGroupDict.Add oGroup.Name, "-"
Next
Set oUser = Nothing
End If
IsMember = CBool(g_oGroupDict.Exists(sGroup))
End Function

'groupe Informatique'

If IsMember("informatique") then
If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\INFO-HP9040DN-INO105"
net.AddWindowsPrinterConnection "\\PHI\INFO-C782-INO100"
net.AddWindowsPrinterConnection "\\PHI\INFO-HPL5000N-INO84"
net.AddWindowsPrinterConnection "\\PHI\INFO-HP4050TN-INO78"
net.AddWindowsPrinterConnection "\\PHI\INFO-RICOH-AFICIOAP3800C-INO87"
net.AddWindowsPrinterConnection "\\PHI\INFO-IBM4324-INO61"

net.SetDefaultPrinter "\\PHI\INFO-HPL5000N-INO84"

net.AddWindowsPrinterConnection "\\PI\INFO-HP9040DN-INO105"
net.AddWindowsPrinterConnection "\\PI\INFO-C782-INO100"
net.AddWindowsPrinterConnection "\\PI\INFO-HPL5000N-INO84"
net.AddWindowsPrinterConnection "\\PI\INFO-HP4050TN-INO78"
net.AddWindowsPrinterConnection "\\PI\INFO-RICOH-AFICIOAP3800C-INO87"
net.AddWindowsPrinterConnection "\\PI\INFO-IBM4324-INO61"

'montage menu'

Dim Shell, DesktopPath, URL
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

End if

'groupe catalogue'

If IsMember("catalogue") then
'If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\HP4050-MR"
net.SetDefaultPrinter "\\PHI\HP4050-MR"

'montage menu'

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

End if

'groupe compta'

If IsMember("compta") then
'If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"
res.RemoveNetworkDrive "F:"
res.MapNetworkDrive "F:", "\\psi\sys"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\COMPTA-HPL8150DN-INO88"
net.AddWindowsPrinterConnection "\\PHI\COMPTA-HPL5000N-INO99"
net.AddWindowsPrinterConnection "\\PHI\COMPTA-HPL4050-INO92"
net.AddWindowsPrinterConnection "\\PHI\MARKETING-HP5550-INO102"

net.AddWindowsPrinterConnection "\\PI\COMPTA-HPL8150DN-INO88"
net.AddWindowsPrinterConnection "\\PI\COMPTA-HPL5000N-INO99"
net.AddWindowsPrinterConnection "\\PI\COMPTA-HPL4050-INO92"
net.AddWindowsPrinterConnection "\\PI\MARKETING-HP5550-INO102"

'montage menu'

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

End If

'groupe direction'

If IsMember("direction") then
'If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\k5400_LW"

net.SetDefaultPrinter "\\PHI\k5400_LW"

net.AddWindowsPrinterConnection "\\PI\k5400_LW"

'montage menu'

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

End if

'groupe logistique'

If IsMember("logistique") then
'If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\LOGISTIQUE-HP5400-INO70"
net.AddWindowsPrinterConnection "\\PHI\LOGISTIQUE-HP4200-INO93"
net.AddWindowsPrinterConnection "\\PHI\LOGISTIQUE-HP4015-INO103"

net.AddWindowsPrinterConnection "\\PI\MARKETING-HPL4000TN-INO68"
net.AddWindowsPrinterConnection "\\PI\LOGISTIQUE-HP4015-INO103"
net.AddWindowsPrinterConnection "\\PI\LOGISTIQUE-HP4015-INO103"

'montage menu'

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

End if

'groupe marketing'

If IsMember("marketing") then
'If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\MARKETING-HPL4000TN-INO68"

net.AddWindowsPrinterConnection "\\PHI\MARKETING-HP5550-INO102"
net.AddWindowsPrinterConnection "\\PHI\MARKETING-HPL5100-INO93"
net.AddWindowsPrinterConnection "\\PHI\CATALOGUE-HPL5000-INO76"
net.AddWindowsPrinterConnection "\\PHI\CATALOGUE-HPL4100-INO83"

net.AddWindowsPrinterConnection "\\PI\MARKETING-HPL4000TN-INO68"

net.AddWindowsPrinterConnection "\\PI\MARKETING-HP5550-INO102"
net.AddWindowsPrinterConnection "\\PI\MARKETING-HPL5100-INO93"
net.AddWindowsPrinterConnection "\\PI\CATALOGUE-HPL5000-INO76"
net.AddWindowsPrinterConnection "\\PI\CATALOGUE-HPL4100-INO83"

'montage menu'

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

End if

'groupe Rclient saisie'

If IsMember("Rclientsaisie") then
'If (fso.folderexists("U:\") = False) Then
res.MapNetworkDrive "U:", "\\SAN\USERS"
Else

'montage disque'

res.RemoveNetworkDrive "U:"
res.MapNetworkDrive "U:", "\\SAN\USERS"

'mise a l'heure'
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Cmd.exe /c net time %LOGONSERVER% /yes"

'montage imprimante'

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\PHI\RCLIENT-HPL8100DN-INO73"
net.AddWindowsPrinterConnection "\\PHI\RCLIENT-HPL4200DN-INO94"
net.AddWindowsPrinterConnection "\\PHI\RCLIENT-HPL4050-INO77"
net.AddWindowsPrinterConnection "\\PHI\RCLIENT-HPL4100N-INO90"

net.AddWindowsPrinterConnection "\\PI\RCLIENT-HPL8100DN-INO73"
net.AddWindowsPrinterConnection "\\PI\RCLIENT-HPL4200DN-INO94"
net.AddWindowsPrinterConnection "\\PI\RCLIENT-HPL4050-INO77"
net.AddWindowsPrinterConnection "\\PI\RCLIENT-HPL4100N-INO90"

'montage menu'

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\menu.lnk")
URL.TargetPath = "\\Delta\APP_ALL\ApGlobal\Menu"
URL.Save

'montage des fichiers'
Set fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFile "\\DELTA\APP_ALL\APGLOBAL\MENU\RELATIONS_CLIENT", "%USERPROFILE%\Bureau\"
fso.CopyFile "\\Delta\APP_ALL\ApGlobal\Menu\Saisie\", "%USERPROFILE%\Bureau\"

End if

wscript.quit
A voir également:

1 réponse

globalscript Messages postés 14 Statut Membre 6
 
Bonjour,

Très franchement, un script de cette taille sans gestion des erreurs , sans journalisation dans un fichier texte et sans reelle compétences en scripting...

ca va etre difficile a debuguer...

J'ai développé un outil gratuit permettant de générer des scripts d'ouverture de session a partir d'une interface graphique...
...ca peut etre utile pour les non-developpeurs.

visitez http://globalscript.free.fr
0