process termination not working correctly in script
Posted: Sat Sep 28, 2019 2:57 pm
I'm not sure why, but neither version of the below process termination functions work correctly when added to an killswitch script. In both versions the scripts in unresponsive and does not close qbittorrent.exe. When run as a disconnect script, the disconnecting process hangs until qbitorrent is manually terminated. Any ideas as to what could be causing this?
Code: Select all
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'qbittorrent.exe'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WSCript.Echo "Just killed process " & strProcessKill _
& " on " & strComputer
WScript.Quit
' End of WMI Example of a Kill Process
Code: Select all
Taskkill /IM qbittorrent.exe /F