Client connect/disconnect scripting on Windows 7
Posted: Mon Feb 05, 2018 9:21 am
I am currently using a script which runs nightly to move some backup data from my Win7 PC to a server.
In order to do that I am connecting a PPTP Windows VPN via a bat file in advance of running the backup job.
At the end of the job the VPN tunnel is disconnected. This has worked fine for years but now the PPTP VPN is about to be discontinued due to the age of the server running RRAS.
Instead there is now an OpenVPN server on the remote LAN, so I would like to be able to do the same as above but with OpenVPN.
But when I google this (as I thought pretty straightforward) problem it turns out that everywhere I look there seems to only be solutions for the connection and none for the disconnect....
Is it really so that with OpenVPN on Windows there is no way to automate both the connect and disconnect to an OpenVPN server via a bat file?
In my case the three bat files run as scheduled tasks with a set user ID.
They run in sequence at fixed times:
1) Connect VPN: rasdial <VPNProfileName> <username> <userpwd>
2) Run the backup job
3) Disconnect VPN: rasdial <VPNProfileName> /disconnect"
Is there anything similar available for OpenVPN?
Notice that I have a lot of different OVPN connections registered with OpenVpn-GUI so a solution tha connects a "default" connection will not cut it.
Neither can a "solution" where openvpn is killed because I have other connections also running, which need to continue to be connected.
In order to do that I am connecting a PPTP Windows VPN via a bat file in advance of running the backup job.
At the end of the job the VPN tunnel is disconnected. This has worked fine for years but now the PPTP VPN is about to be discontinued due to the age of the server running RRAS.
Instead there is now an OpenVPN server on the remote LAN, so I would like to be able to do the same as above but with OpenVPN.
But when I google this (as I thought pretty straightforward) problem it turns out that everywhere I look there seems to only be solutions for the connection and none for the disconnect....
Is it really so that with OpenVPN on Windows there is no way to automate both the connect and disconnect to an OpenVPN server via a bat file?
In my case the three bat files run as scheduled tasks with a set user ID.
They run in sequence at fixed times:
1) Connect VPN: rasdial <VPNProfileName> <username> <userpwd>
2) Run the backup job
3) Disconnect VPN: rasdial <VPNProfileName> /disconnect"
Is there anything similar available for OpenVPN?
Notice that I have a lot of different OVPN connections registered with OpenVpn-GUI so a solution tha connects a "default" connection will not cut it.
Neither can a "solution" where openvpn is killed because I have other connections also running, which need to continue to be connected.