Hello
I have a scheduled task on WS03. It is a VBScript file that edits a text file, then restarts tomcat using a command window.
My (novice) code to restart the service is
Dim objShell, intShortSleep, intLongSleep
Dim strService
Set objShell = CreateObject("WScript.Shell")
' Values set
strService = " tomcat5"
intShortSleep = 500
intLongSleep = 3000
' Cmd prompt opened
objShell.Run "cmd"
WScript.Sleep intShortSleep
' Service stopped
objShell.SendKeys "net stop" & strService
WScript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
WScript.Sleep intLongSleep
' service restarted
objShell.SendKeys "net start" & strService
WScript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
WScript.Sleep intLongSleep
' Cmd prompt exited
objShell.SendKeys "Exit"
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
When executed manually, it all works fine.
When scheduled, the job reports success (0x0), the text file is edited, but tomcat is not restarted, and the command window is left open when I log into the server. It seems all of the objShell.SendKeys comands are blocked from executing while no one is logged in, is this expected behaviour?
Any help would be much appreciated