Is it possible to stop and start a background service.
There is a third party service that is interfering with an Excel Plug-In. I want to temporarily stop it when I run my code, and then turn it back on at the end.
Is it possible to stop and start a background service.
There is a third party service that is interfering with an Excel Plug-In. I want to temporarily stop it when I run my code, and then turn it back on at the end.
Whenever you want to do something like this a Google using "WMI" will probably get you something useful.
For example -
Set ServiceSet = GetObject("winmgmts:").ExecQuery( _
"select * from Win32_Service where Name='ClipSrv'")
for each Service in ServiceSet
RetVal = Service.StopService()
if RetVal = 0 then
WScript.Echo "Service stopped"
elseif RetVal = 5 then
WScript.Echo "Service already stopped"
end if
next
Set ServiceSet = GetObject("winmgmts:").ExecQuery( _
"select * from Win32_Service where Name='ClipSrv'")
for each Service in ServiceSet
RetVal = Service.StartService()
if RetVal = 0 then WScript.Echo "Service started"
if RetVal = 10 then WScript.Echo "Service already running"
next