Lancement d'une tache planifiée... Problème !
naicoram01
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
cesar -
cesar -
Bonjour,
=> SYS : WINDOWS 2003R2 <=
j'explique mon problème...
j'essaye de planifié une tache qui exécutera un vbScript, ce dernier va récupérer les configs d'un ensemble de switch sur mon reseau.
Dim shell, args, params, fso, fa,fs
Set shell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set args = Wscript.Arguments
Script=Lcase(Wscript.ScriptFullName)
set fs=fso.GetFile(Script)
sps=lcase(fs.ShortPath)
dim tab(20)
tab(0) = 34
tab(1) = 35
tab(2) = 36
tab(3) = 26
tab(4) = 42
tab(5) = 23
tab(6) = 37
tab(7) = 38
tab(8) = 39
tab(9) = 44
tab(10) = 45
tab(11) = 24
tab(12) = 41
tab(13) = 32
tab(14) = 33
tab(15) = 29
tab(16) = 28
tab(17) = 21
tab(18) = 43
tab(19) = 27
For i = 0 To UBound(tab) - 1 Step 1
shell.Run "telnet 192.168.0." & tab(i)
WScript.Sleep 1000
' Test sur les switchs qui ne necessitent pas de 'Entrer' pour passer les Login/MDP
if tab(i) <> 33 And tab(i) <> 32 And tab(i) <> 28 then
shell.sendkeys "{ENTER}"
WScript.Sleep 500
end if
shell.Sendkeys "switch"
shell.sendkeys "{ENTER}"
WScript.Sleep 500
shell.Sendkeys "qs900QS900."
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "copy start tftp 192.168.0.50 SwitchsBackup\config_" & tab(i) & ".cfg"
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "logout"
shell.sendkeys "{ENTER}"
shell.Sendkeys "y"
WScript.Sleep 1000
shell.sendkeys "{ENTER}"
Next
' Traitement le 10.57.0.10
shell.Run "telnet 10.57.0.10"
WScript.Sleep 1000
shell.Sendkeys "switch"
shell.sendkeys "{ENTER}"
WScript.Sleep 500
shell.Sendkeys "qs900QS900."
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "copy start tftp 192.168.1.10 SwitchsBackup\config_10.cfg"
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "logout"
shell.sendkeys "{ENTER}"
shell.Sendkeys "y"
WScript.Sleep 1000
shell.sendkeys "{ENTER}"
le script marche sans AUCUN PROBLÈME quand je l'exécute tout seul.
j'ai crée un compte pour lancer le script avec la tache planifiée.
dans une tache planifiée, rien ne marche !
Merci d'avance pour votre aide :( !
=> SYS : WINDOWS 2003R2 <=
j'explique mon problème...
j'essaye de planifié une tache qui exécutera un vbScript, ce dernier va récupérer les configs d'un ensemble de switch sur mon reseau.
Dim shell, args, params, fso, fa,fs
Set shell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set args = Wscript.Arguments
Script=Lcase(Wscript.ScriptFullName)
set fs=fso.GetFile(Script)
sps=lcase(fs.ShortPath)
dim tab(20)
tab(0) = 34
tab(1) = 35
tab(2) = 36
tab(3) = 26
tab(4) = 42
tab(5) = 23
tab(6) = 37
tab(7) = 38
tab(8) = 39
tab(9) = 44
tab(10) = 45
tab(11) = 24
tab(12) = 41
tab(13) = 32
tab(14) = 33
tab(15) = 29
tab(16) = 28
tab(17) = 21
tab(18) = 43
tab(19) = 27
For i = 0 To UBound(tab) - 1 Step 1
shell.Run "telnet 192.168.0." & tab(i)
WScript.Sleep 1000
' Test sur les switchs qui ne necessitent pas de 'Entrer' pour passer les Login/MDP
if tab(i) <> 33 And tab(i) <> 32 And tab(i) <> 28 then
shell.sendkeys "{ENTER}"
WScript.Sleep 500
end if
shell.Sendkeys "switch"
shell.sendkeys "{ENTER}"
WScript.Sleep 500
shell.Sendkeys "qs900QS900."
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "copy start tftp 192.168.0.50 SwitchsBackup\config_" & tab(i) & ".cfg"
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "logout"
shell.sendkeys "{ENTER}"
shell.Sendkeys "y"
WScript.Sleep 1000
shell.sendkeys "{ENTER}"
Next
' Traitement le 10.57.0.10
shell.Run "telnet 10.57.0.10"
WScript.Sleep 1000
shell.Sendkeys "switch"
shell.sendkeys "{ENTER}"
WScript.Sleep 500
shell.Sendkeys "qs900QS900."
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "copy start tftp 192.168.1.10 SwitchsBackup\config_10.cfg"
shell.sendkeys "{ENTER}"
WScript.Sleep 1000
shell.Sendkeys "logout"
shell.sendkeys "{ENTER}"
shell.Sendkeys "y"
WScript.Sleep 1000
shell.sendkeys "{ENTER}"
le script marche sans AUCUN PROBLÈME quand je l'exécute tout seul.
j'ai crée un compte pour lancer le script avec la tache planifiée.
dans une tache planifiée, rien ne marche !
Merci d'avance pour votre aide :( !
7 réponses
-
Bonjour,
Etes vous sur le meme compte quand vous lancez le script manuellement?? -
Salut
Tu as mis ton code vbScript dans un fichier et tu as créé une tâche pour lancer ce fichier, c'est bien ça ?
-
tout d'abord, merci pour vos reponses
@f894009 : quand je teste le lancement du script manuellement, je suis logger avec mon compte admin. Mais la tache est planifiée avec un compte dediée pour les "taches planifiées"
@CH93 : effectivement, j'ai mi un fichier "script.vbs" qui contient le contenu que j'ai partagé avec vous. -
Re,
quand je teste le lancement du script manuellement, je suis logger avec mon compte admin.
Il faut que le compte dedie soit aussi admin -
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -
effectivement le compte avec lequel est configuré la tache planifiée est admin.
-
en se connectant avec le compte dediée, et en executant le script, tout se passe bien, sans aucun probleme !
-
j'ai essayé avec un fichier bat, ca marche sans probleme
en mettant dans le fichier bat, comme test, le contenu suivant :
ping 10.59.41.10 > g:\test.txt
et ça marche !!
peut être que les script vb ne marche pas dans les taches planifiées !! ou peut être que j'ai un problème avec mon script ?!