This can't be done in Windows without using additional programs, batch files, or the command line. An alternative is to get a virtual (or physical) machine which you can run the VPN on.
It seems strange that something as easily explainable as this is so difficult to achieve. How difficult could it be to just route traffic from one program to the VPN interface and all the other programs to the default NIC interface? Why would we need to set up a whole virtual machine for that? And with Linux it's possible but its solution is not very elegant either.
It's very much sought after too: I came across dozens of threads on the same subject. So I only hope someone realises the ludicrousness of this and do something about it. (In Windows 8!)
This solution is from an unattributed batch file. It has been slightly adapted.
Instructions for Windows 7
The script will connect to and route traffic through your VPN until a reboot - you can replace
route add with
route -p add for the change to persist, but if you don't have a persistent IP with your VPN, it will eventually stop working when your VPN IP changes.
- Open the Network and Sharing Center
- Open the properties for your VPN connection
- Click the
- For both IPv4 and 6:
Use default gateway[...]
- Close everything opened from the previous steps
- Edit and save the batch script found below
- Run it as an administrator
You need to replace the following in the script:
<VPN> with the Name of the VPN connection you created
<USER> with the VPN username
<PASS> with the VPN password
<TARGET> with the IP address you want routed through the VPN (if you want to route more addresses, simply duplicate the three lines where the target is used)
Note: If you don't want to save the password in the file, replace
%password% and add the following after the first line of the script:
set password= Input password:.
@echo make sure to be disconnected!
rasdial <VPN> /d
@echo start to connect to vpn
rasdial <VPN> <USER> <PASS>
netsh interface ip show config name="<VPN>" | findstr "IP" > ip.dat
set /p ip= < ip.dat
@echo VPN IP is %ip%
@echo Add route for %target%
route add %target% mask 255.255.255.255 %ip%
timeout /T 3 > nul