I have a script where i need to terminate running tasks, run somethings on another server, then restart the tasks on the first server. The problem is i am not able to terminate these specific tasks. I can terminate other tasks using the code below (just changing the .exe) but not the one specified. I can end task in Task Monitor but not via script. Does anyone have any ideas why this would not work on all tasks?
CODE SNIPET
Function ctBroker
WScript.Echo "killing CtBroker"
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'CtBroker.exe'"
'Set objsrv2 = GetObject("winmgmts:" _
' & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process"
For Each objProcess in colProcesses
objProcess.Terminate(0)
WScript.Echo "Is CTbroker Dead?"
Next
End Function
CODE SNIPET
Function ctBroker
WScript.Echo "killing CtBroker"
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'CtBroker.exe'"
'Set objsrv2 = GetObject("winmgmts:" _
' & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process"
For Each objProcess in colProcesses
objProcess.Terminate(0)
WScript.Echo "Is CTbroker Dead?"
Next
End Function