Besoin d'aide sur du VBscript a interfacer avec un Serveur nas et un Windows.
---------------------------------------------------------------------------
Voilà mon problème :
J'ai créé un VBscript qui me permet de mapper les drives d'un Serveur Nas
ce script dé-map les drives du Serveur puis les re-map, comme cela ça permet de mapper de façon sûr.
J'avais l'intention de mettre ce script dans le démarrage de XP mais voilà le problème, cela fonctionne une fois tous les X, car il arrive souvent que le réseau ne soit pas encore actif là ou XP exécute le script ; alors dans ce cas rien ne se fait
Comment pourait on faire démarrer ce script au démarrage d'un Windows, tout en connaissant si le réseau est actif pour le faire et de patienter si ce dernier n'est pas actif avant de lancer le script ?
Je suis preneur de toutes solutions, même en VBScript en complément de mon prg pour tester si le LAn et actif ou non avant de lancer mon script.
Voici ci dessous le contenu de mon fichier.vbs
' / Serveur Nas connection share ressources /
' declarations
option explicit
Dim objnetwork, objfile, objfolder, objfso, objshell, checkdrive
Dim intdrive, alreadyconnected, intbcl
Dim strdrv, strmap, strmapS, struser, strpwd
' initialisation for network
set objfso = createobject("Scripting.filesystemobject" )
set objnetwork = createobject("wscript.network" )
' initialisation for shell command
set objshell= createobject("wscript.shell" )
set checkdrive =objnetwork.enumnetworkdrives()
' Pass on error to next full command
On error resume next
' Delete all mapped drive linked or not
for intbcl = 1 to 8
select case intbcl
Case 1
strdrv = "L:"
strmap ="\\Diskstation\Html"
strmapS ="\\Diskstation\Html$"
Case 2
strdrv = "M:"
strmap ="\\Diskstation\Workhome"
strmapS ="\\Diskstation\Workhome$"
Case 3
strdrv = "N:"
strmap ="\\Diskstation\Private"
strmapS ="\\Diskstation\Private$"
case 4
strdrv = "O:"
strmap ="\\Diskstation\Temp"
strmapS ="\\Diskstation\Temp$"
case 5
strdrv = "P:"
strmap ="\\Diskstation\Common"
strmapS ="\\Diskstation\Common$"
case 6
strdrv = "Q:"
strmap ="\\Diskstation\Exchange"
strmapS ="\\Diskstation\Exchange$"
Case 7
strdrv = "R:"
strmap ="\\Diskstation\Advance"
strmapS ="\\Diskstation\Advance$"
Case 8
strdrv = "S:"
strmap ="\\Diskstation\Public"
strmapS ="\\Diskstation\Public$"
end select
if objfso.DriveExists(strdrv) then
objnetwork.removenetworkdrive strdrv, True, True
'objshell.popup "Map drive " & strmap & " - " & strdrv & " disconnected successfully"
end if
next
' Connect all mapped drive
for intbcl = 1 to 8
' init var to false
alreadyconnected = False
select case intbcl
Case 1
strdrv = "L:"
strmap ="\\Diskstation\Html"
strmapS ="\\Diskstation\Html$"
struser = "myuser"
strpwd = "synology"
Case 2
strdrv = "M:"
strmap ="\\Diskstation\Workhome"
strmapS ="\\Diskstation\Workhome$"
struser = "myuser"
strpwd = "synology"
Case 3
strdrv = "N:"
strmap ="\\Diskstation\Private"
strmapS ="\\Diskstation\Private$"
struser = "myuser"
strpwd = "synology"
case 4
strdrv = "O:"
strmap ="\\Diskstation\Temp"
strmapS ="\\Diskstation\Temp$"
struser = "myuser"
strpwd = "synology"
case 5
strdrv = "P:"
strmap ="\\Diskstation\Common"
strmapS ="\\Diskstation\Common$"
struser = "myuser"
strpwd = "synology"
case 6
strdrv = "Q:"
strmap ="\\Diskstation\Exchange"
strmapS ="\\Diskstation\Exchange$"
struser = "myuser"
strpwd = "synology"
Case 7
strdrv = "R:"
strmap ="\\Diskstation\Advance"
strmapS ="\\Diskstation\Advance$"
struser = "myuser"
strpwd = "synology"
Case 8
strdrv = "S:"
strmap ="\\Diskstation\Public"
strmapS ="\\Diskstation\Public$"
struser = "myuser"
strpwd = "synology"
end select
if objfso.folderexists(strmapS) then
objnetwork.mapnetworkdrive strdrv, strmapS, False, struser, strpwd
alreadyconnected = True
elseif objfso.folderexists(strmap) then
objnetwork.mapnetworkdrive strdrv, strmap, False, struser, strpwd
alreadyconnected = True
end if
' confirm failed connection
if alreadyconnected = False then
objshell.popup "Map nas drive " & strmap & " - " & strdrv & " failed to reconnect"
end if
next
' end of script
Wscript.quit
Merci à tous
Steely
Message édité par steelywolf le 15-06-2006 à 19:11:40