Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
This is the code, which you will use for stop Services using VBS Script
Function StopServices Dim objWMIService,colItems,ObjItem,chkServiceStatus,RetVal Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where name='" & strServiceName & "'",,48) For Each ObjItem in colItems If (InStr (1,objItem.DisplayName,strServiceName,1) > 0) then chkServiceStatus=ObjItem.State end if Next If(ucase(chkServiceStatus)="RUNNING") THEN RetVal = goShell.Run("%windir%\system32\sc.exe Stop """ & strServiceName & """ >> " & gcsLogFile,0,True) Do Until(Ucase(ServiceStatus)="STOPPED") Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where name='" & strServiceName & "'",,48) For Each ObjItem in colItems If (InStr (1,objItem.DisplayName,strServiceName,1) > 0) then ServiceStatus=ObjItem.State end if Next Loop End If
End Function