Hi , everybody.
I?m new in the world of vbs, and I need big help for a script in Windows 2000 Advanced Server and Windows 2000 Professional.
This script works perfectly when I do double click on it, but when I try to program a task with the scheduler (AT and Task Scheduler of Windows), Windows says that it?s running, and when the task is finalized, there is only the file that is before WshShell.Run "cmd.exe". The name of the file is num2.txt, that is created, but not edited.
That means that the script do the first orders, but when it arrives to this point, it doesn?t continues with the next instructions.
I tried to manipulate the style of window, but how the script uses keystrokes, only works to me with style 9.
This is the code:
Arxiu = "IP.txt"
xml = "user.xml"
Set filesys = CreateObject("Scripting.FileSystemObject")
if filesys.FileExists(Arxiu) then
Const ForReading = 1
Dim f, ip
Set f = filesys.OpenTextFile(Arxiu, ForReading)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe", 9
Do Until f.AtEndOfStream
ip = f.ReadLine
Wscript.Sleep 1600
Set aux= filesys.CreateTextFile("num2.txt", True)
aux.WriteLine (vbcrlf + vbcrlf + ip)
aux.WriteLine (Date + Time)
aux.Close
Wscript.Sleep 1000
WshShell.SendKeys "cpqlocfg -s " + ip + " -l " + ip + ".log -f " + xml + " > Resultat" + ip + ".txt -v" + "{Enter}"
Wscript.Sleep 10000
WshShell.SendKeys "copy num2.txt {+} Resultat" + ip + ".txt num.txt" + "{Enter}"
Wscript.Sleep 1000
WshShell.SendKeys "type num.txt >> Log" + Arxiu + "{Enter}"
Wscript.Sleep 1600
WshShell.SendKeys "del num.txt num2.txt" + "{Enter}"
Wscript.Sleep 1000
if ip = NULL then
Exit Do
End if
Loop
else
WshShell.SendKeys "Incorrect File"
Wscript.Sleep 1000
End If
WshShell.SendKeys "exit" + "{Enter}"
Set WshShell = nothing The program calls another program (CPQLOCFG), and it sends to it the parameters to execute. These parameters are included inside the file IP.txt (it?s full with ip address). the script is full of redirections for save all the events.
Thanks for your help, and sorry by my poor level of english.