kwatt562
asked on
vbs to stop Sophos services prior to removal
I have a script to stop all services as a pre-deployment task prior to uninstalling Sophos from a Windows 7 PC.
The works fine when I deploy manually on the PC and stops all the services. However via the deployment tool, the services don't stop. When I monitor processes I do see wscript running and among other things trustedinstaller. I am possibly thinking that the script runs, but the services haven't stopped before the uninstallation begins. The script is below, any idea on how to stop the script from finishing until all services were stopped? (to test this theory)
StopService ".", "Sophos Agent", True
StopService ".", "SAVService", True
StopService ".", "SAVAdminService", True
StopService ".", "Sophos AutoUpdate Service", True
StopService ".", "Sophos Device Control Service", True
StopService ".", "Sophos Message Router", True
StopService ".", "Sophos Web Control Service", True
StopService ".", "swi_service", True
Sub StopService(Computer, ServiceName, Wait)
Dim cimv2, oService, Result
'Get the WMI administration object
Set cimv2 = GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\" & _
Computer & "\root\cimv2")
'Get the service object
Set oService = cimv2.Get("Win32_Service.N ame='" & ServiceName & "'")
'Stop the service
Result = oService.StopService
The works fine when I deploy manually on the PC and stops all the services. However via the deployment tool, the services don't stop. When I monitor processes I do see wscript running and among other things trustedinstaller. I am possibly thinking that the script runs, but the services haven't stopped before the uninstallation begins. The script is below, any idea on how to stop the script from finishing until all services were stopped? (to test this theory)
StopService ".", "Sophos Agent", True
StopService ".", "SAVService", True
StopService ".", "SAVAdminService", True
StopService ".", "Sophos AutoUpdate Service", True
StopService ".", "Sophos Device Control Service", True
StopService ".", "Sophos Message Router", True
StopService ".", "Sophos Web Control Service", True
StopService ".", "swi_service", True
Sub StopService(Computer, ServiceName, Wait)
Dim cimv2, oService, Result
'Get the WMI administration object
Set cimv2 = GetObject("winmgmts:{imper
Computer & "\root\cimv2")
'Get the service object
Set oService = cimv2.Get("Win32_Service.N
'Stop the service
Result = oService.StopService
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.