Avatar of skeider
skeider
Flag for United States of America

asked on 

How to schedule a service to stop using vbscript

I am trying to create a script that will create a scheduled job that will stop a windows service.  I know that I can use schtasks, but am having difficulties when the executable requires parameters.  I have been trying to use NET STOP in order to stop the service.  I know that I could alternatelyuse SC.exe STOP, but both require the service name as a parameter and in many cases the service name contains spaces.

How can I make this work?  
Set objShell= WScript.CreateObject("WScript.Shell")
strTask =  "schtasks /create /tn ""Stop_WWW" /tr ""net stop ""World Wide Web Publishing"""" /sc minute /mo 5 /ru System"
objShell.Run strTask,2,true

Open in new window

VB ScriptScripting LanguagesWindows XP

Avatar of undefined
Last Comment
skeider

8/22/2022 - Mon