process termination not working correctly in script

Got a problem with Viscosity or need help? Ask here!

n8chavez

Posts: 19
Joined: Sat Aug 15, 2015 3:53 pm

Post by n8chavez » 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

n8chavez

Posts: 19
Joined: Sat Aug 15, 2015 3:53 pm

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

Eric

User avatar
Posts: 1146
Joined: Sun Jan 03, 2010 3:27 am

Post by Eric » Mon Sep 30, 2019 9:55 am
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
Eric Thorpe
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs

n8chavez

Posts: 19
Joined: Sat Aug 15, 2015 3:53 pm

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

Eric

User avatar
Posts: 1146
Joined: Sun Jan 03, 2010 3:27 am

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

Do these scripts function correctly if just double clicked?

Regards,
Eric
Eric Thorpe
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs

n8chavez

Posts: 19
Joined: Sat Aug 15, 2015 3:53 pm

Post by n8chavez » Tue Oct 01, 2019 3:15 pm
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?

Eric

User avatar
Posts: 1146
Joined: Sun Jan 03, 2010 3:27 am

Post by Eric » Wed Oct 02, 2019 4:22 pm
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
Eric Thorpe
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs
7 posts Page 1 of 1