Connect/Disconnect Scripts

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

Wayland77

Posts: 2
Joined: Fri Jan 15, 2021 10:40 pm

Post by Wayland77 » Fri Jan 15, 2021 10:46 pm
Hi there

I've written a (very) simple 2 line batch script to map a network share when I connect to a VPN.

@echo off
net use T: \\192.168.1.3\sharename /persistent:no

All works fine when I run the script manually. But when I add it as the connected script, the drive doesn't get added.

Any help greatly appreciated.

Thanks.

Mike

Eric

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

Post by Eric » Wed Jan 20, 2021 9:00 am
Hi Mike,

Please ensure the script has been added by clearing it and adding it again to your configuration and saving. The script is copied so if you modified it after adding it, those changes have not been added.

Depending on your configuration, it can take a few seconds for Windows routes to become active, you may need to add a small delay to your batch script before calling net use.

Finally, ensure nothing is blocking the script from running like AV software.

Regards,
Eric
Eric Thorpe
Viscosity Developer

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

asdffdsa6131

Posts: 30
Joined: Sat Feb 23, 2019 12:15 pm

Post by asdffdsa6131 » Thu Jan 28, 2021 7:58 am
hi,

having the similar problem.
script is not run after connect but runs from command line.

as you suggested, i tried this but did not help.
"clearing it and adding it again to your configuration and saving"

this is the script
note: amsg.exe display whatever text it is passed. i add this when testing.
i made sure to use full paths.
-------------------
C:\data\C\BitviseSSHClient\profiles\home\local\amsg.exe test
C:\data\C\BitviseSSHClient\stnlc.exe -noRegistry -profile=C:\data\C\BitviseSSHClient\profiles\home\local\opnsense.local.asdffdsa.tlp
-------------------------

thanks in advance

Eric

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

Post by Eric » Fri Jan 29, 2021 9:51 am
Hi asdffdsa6131,

Please create a new script with the following contents and name it "connected.bat":
Code: Select all
@echo off
start "" https://www.sparklabs.com
Set this as your connected script and connect, this should open our website in your default browser when connected. Please let us know if this works or not.

Regards,
Eric
Eric Thorpe
Viscosity Developer

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

asdffdsa6131

Posts: 30
Joined: Sat Feb 23, 2019 12:15 pm

Post by asdffdsa6131 » Fri Jan 29, 2021 10:05 am
hi,

fyi, it is confusing to continue an existing post, as now, i cannot see the previous posts in this chain.

i followed your advice,
created a new .cmd file with that text.
using the gui, i cleared the existing script entry.
i pointed the gui to the new .cmd file.
i noticed that the gui copied the .cmd file to C:\Users\user01\AppData\Roaming\Viscosity\OpenVPN\2\stnlc-opnsense.local.asdffdsa.cmd

that script is not getting executed when the vpn connects.

if i run that script manually, it does open the website.

if i look inside C:\Users\user01\AppData\Roaming\Viscosity\OpenVPN\2\config.conf, i see
#viscosity connectedscript stnlc-opnsense.local.asdffdsa.cmd

thanks for the quick reply,
david

Eric

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

Post by Eric » Mon Feb 01, 2021 9:18 am
Hi,

The script needs to be a .bat file for Viscosity to execute it.

Regards,
Eric
Eric Thorpe
Viscosity Developer

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

Wayland77

Posts: 2
Joined: Fri Jan 15, 2021 10:40 pm

Post by Wayland77 » Fri Feb 05, 2021 1:55 am
Hi Eric

Many thanks for the help. I inserted a TIMEOUT 4, which fixed the problem.

Regards
Mike
7 posts Page 1 of 1