Page 1 of 1

Connect/Disconnect Scripts

Posted: Fri Jan 15, 2021 10:46 pm
by Wayland77
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

Re: Connect/Disconnect Scripts

Posted: Wed Jan 20, 2021 9:00 am
by Eric
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

Re: Connect/Disconnect Scripts

Posted: Thu Jan 28, 2021 7:58 am
by asdffdsa6131
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

Re: Connect/Disconnect Scripts

Posted: Fri Jan 29, 2021 9:51 am
by Eric
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

Re: Connect/Disconnect Scripts

Posted: Fri Jan 29, 2021 10:05 am
by asdffdsa6131
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

Re: Connect/Disconnect Scripts

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

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

Regards,
Eric

Re: Connect/Disconnect Scripts

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

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

Regards
Mike