Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Control VPN Connection

If you have a question or need help, this is the place to be.
Post Reply
adam6806
Posts: 1
Joined: Thu Aug 23, 2012 3:30 am

Control VPN Connection

Post by adam6806 »

I've been searching around to no avail. Here is the situation. At specific times I want my computer to use a vpn connection and at certain times my normal connection. I would like to use eventghost to turn my vpn connection on and off at specific times.... Anyone?
bskchaos
Experienced User
Posts: 56
Joined: Tue Mar 25, 2008 3:04 pm

Re: Control VPN Connection

Post by bskchaos »

What kind of VPN? If you are using OpenVPN you can use command line to start and stop the client.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Control VPN Connection

Post by Pako »

I just tested the VPN connection/disconnection in Windows 7.
It works very reliably. I did it as follows:
VPNon-off.png
VPNon-off.png (7.12 KiB) Viewed 2007 times
And here are the scripts:
Connection:

Code: Select all

VPNname = "name of my VPN connection"
VPNusername = "my VPN username"
VPNpassword = "my VPN password"
from subprocess import Popen, SW_HIDE
args = ["rasdial"]
args.append('"%s"' % VPNname)
args.append(VPNusername)
args.append(VPNpassword)
Popen(args,  creationflags=SW_HIDE, shell=True)
Disconnection:

Code: Select all

VPNname = "name of my VPN connection"
from subprocess import Popen, SW_HIDE
args = ["rasdial.exe"]
args.append('"%s"' % VPNname)
args.append("/disconnect")
Popen(args,  creationflags=SW_HIDE, shell=True)
Pako
Post Reply