Page 1 of 1

process termination not working correctly in script

Posted: Sat Sep 28, 2019 2:57 pm
by n8chavez
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

Re: process termination not working correctly in script

Posted: Sat Sep 28, 2019 3:15 pm
by n8chavez
I am running Viscosity as admin, so I know it's not a permissions issue.

Re: process termination not working correctly in script

Posted: Mon Sep 30, 2019 9:55 am
by Eric
Hi n8chavez,

It sounds like an AV program may be intercepting the script, do you have any AV or Firewall software running? Do these scripts function correctly if just double clicked?

Regards,
Eric

Re: process termination not working correctly in script

Posted: Mon Sep 30, 2019 5:55 pm
by n8chavez
Nope. I don't run any resident security software other than browser isolation and imaging.

Re: process termination not working correctly in script

Posted: Tue Oct 01, 2019 11:39 am
by Eric
Hi n8chavez,

Do these scripts function correctly if just double clicked?

Regards,
Eric

Re: process termination not working correctly in script

Posted: Tue Oct 01, 2019 3:15 pm
by n8chavez
Yes they do. I've tried running killswitch.bat in each configs' extra configuration section using
Code: Select all
route-pre-down "C:\\Program Files\\Common Files\\Viscosity\\Scripts\\KILLSWITCH.bat"
and it doesn't work, and also in the configs' disconnect script field and it doesn't work there either. Since I'm running viscosity as admin, could be version 1.8 (1627) causing the issue?

Re: process termination not working correctly in script

Posted: Wed Oct 02, 2019 4:22 pm
by Eric
Hi n8chavez,

We've done some extensive testing and we're unable to find a problem using taskkill in a batch script. The route-pre-down script option is executed by the service, so running Viscosity as Admin will have no effect.

Please ensure you have enabled AllowOpenVPNScripts option as per - https://sparklabs.com/support/kb/article/preventing-network-and-dns-traffic-leaks/#preventing-network-leaks-when-a-drop-out-disconnect-occurs

It's possible this application has some methods in place to prevent a force kill from a user that it is not running as. I'd recommend testing your script with an application like Notepad (notepad.exe) to see if the script successfully kills it as it is an extremely simple application that will show no resistance.

Regards,
Eric