Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know I can create a batch file to initiate a VPN connection followed by an RDP session, however I want to know if it's possible (in Windows 7 and ideally Windows XP as well) to have the VPN connection tied to the RDP session status.

Scenario: user has to VPN first in order to be able to RDP. Ideally user would click one icon (batch file?) to initiate VPN connection and load RDP session. When they close the RDP session I want the VPN to then automatically disconnect so they don't accidentally route their subsequent non-RDP browsing + Internet activity through the VPN.

share|improve this question
    
Are you in control of the VPN? –  KronoS Mar 27 '12 at 15:45
    
No but can request some changes if necessary. Why? –  Josh Newman Mar 27 '12 at 15:47
    
Depending on how the VPN is setup traffic may not be routed through the tunnel unless it's for specific resources within that virtual network. Ultimately, no matter what the setup is your user will have to take the responsibility of turning off the tunnel. –  KronoS Mar 27 '12 at 15:51
    
Ok thanks - the disconnection was the key part. So I'll look at routing only RDP traffic through the VPN in case they leave it connected. Apparently if I uncheck ‘use default gateway on remote network’ under TCP/IP settings for the VPN, that should do it. –  Josh Newman Mar 27 '12 at 17:52

1 Answer 1

If you have a standalone VPN client program (i.e. Cisco AnyConnect), use Google to find commandline options for that product to see if you can connect with a single command. For example: AnyConnect, the generic Cisco client, and the Windows VPN client all support this. This might require you to store your password in plaintext in a batch file or script, however.

Once you have that info, write a batch file which invokes the VPN client, probably sleeps a few seconds to make sure the VPN link is good, and then calls the remote desktop client from the command line.

If you wanted to be really fancy, instead of a sleep to verify connectivity, you could have a ping to some resource that's only accessible over the VPN, and have the script return an error if that ping doesn't succeed.

Take your batch file, put it (or a shortcut) on your Desktop or wherever, and then you have a one-click "connect to the VPN and then open Remote Desktop" app.

If, on the other hand, if your VPN client is such that you can't connect via the command line, I'd look into AutoIT or other mouse/keyboard macro scripting languages to see if you can automate VPN connection.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.