noche
Programmer
- Jan 28, 2009
- 1
Hello,
my script must launch some schedule tasks on remote servers. It works if the command is well written and in general with the rights it's OK. But when the command is wrong, I don't have any notification about an error and i could believe the command was successful.
(by exemple, if I made an error on getting the password or if the path is wrong, nothing alerts me).
Here is the code :
I have tried to put cmd & > C:\toto.txt but I just get success, not errors. why?
Thanks by advance for any help or comment,
Noche
my script must launch some schedule tasks on remote servers. It works if the command is well written and in general with the rights it's OK. But when the command is wrong, I don't have any notification about an error and i could believe the command was successful.
(by exemple, if I made an error on getting the password or if the path is wrong, nothing alerts me).
Here is the code :
Code:
Set fso = Wscript.createObject("Scripting.FileSystemObject")
Set oShell = Wscript.createObject("Wscript.Shell")
....
'Lancement du fichier
Set oInput = fso.openTextFile(scriptPath & "input.txt",1,False)
Do Until oInput.AtEndOfStream
sRead = oInput.readline
If left(sRead, 1) <> "'" Then
If InStr(sRead,";") > 0 And Left(sRead,1) <> "'" Then
array_Server = Split(sRead,";")
If UBOUND(array_Server) < 1 Then
Wscript.quit
End If
err.clear
genMinutes
strServer = array_Server(0)
DomainControl=DC(strServer)
'Wscript.echo DomainControl
sCmd="schtasks /create /tn Task /tr \\toto\truc.cmd /sc daily /st 05:11:00 /s "& strServer &" /u domain\login /p """& sPassword &""""
wscript.echo sCmd
sCmd=sCmd & ">" & cfile
Wscript.echo sCmd
sReturn =oShell.Run(sCmd,0,True)
If err <> 0 Then
MsgBox ("Erreur N°" & CStr(Err.Number) & " " & err.Description)
echo err.Number & " " & err.Description
End if
End If
End If
Loop
I have tried to put cmd & > C:\toto.txt but I just get success, not errors. why?
Thanks by advance for any help or comment,
Noche