Board index » Visual Studio » Script Not Working Properly
|
lupegarcia
|
Script Not Working Properly
Visual Studio52
Hello, I have a script that restarts a service, I have it running from the Task Scheduler under Administrator. If I double click the script, it runs great, however, when the Task Scheduler runs it, the command prompt opens and nothing happens, it just sits there and the window never closes (the commands are never sent to the prompt). Below is the script: Option Explicit Dim objShell, intShortSleep, intLongSleep Dim strService Set objShell = CreateObject("WScript.Shell") ' Values set strService = "My Service" intShortSleep = 1500 intLongSleep = 5500 ' Cmd prompt opened objShell.Run "cmd" Wscript.Sleep intShortSleep ' Service stopped with 'Net' command objShell.SendKeys "net stop " & chr(34) & strService & chr(34) Wscript.Sleep intShortSleep objShell.SendKeys "{Enter}" Wscript.Sleep intLongSleep ' Service started with 'Net' command objShell.SendKeys "net start " & chr(34) & strService & chr(34) Wscript.Sleep intShortSleep objShell.SendKeys "{Enter}" Wscript.Sleep intLongSleep ' Cmd prompt exitedExit objShell.SendKeys "Exit" Wscript.Sleep intShortSleep objShell.SendKeys "{Enter}" Any Assistance is Greatly Appreciated, Chuck - |
