Windows 7 default VPN - Single Click to Connect

6

2

The default way to connect to a VPN (standard includedd MS client) seems to be to click on the network icon in the system tray to expand it, then pick the VPN connection, and click the connect button. This brings up a dialog where you can enter your username and password.

I have told the VPN connection to remember my credentials. Is there some way I can skip that dialog and just have it connect?

I have tried using rasdial.exe, and I can connect as long as I pass the username and password as arguments. It doesn't seem to want to use the stored credentials for some reason, maybe I need to store them with an elevated account.

Goyuix

Posted 2010-02-09T01:30:42.780

Reputation: 6 021

Answers

7

You can use rasphone.exe to dial a connection using stored credentials:

rasphone -d "VPN NAME"

Hangup with:

rasphone -h "VPN NAME"

You'll also need to go into the option tab of the properties for your VPN connection and uncheck "Prompt for name and password, certificate, etc."

Jules

Posted 2010-02-09T01:30:42.780

Reputation: 86

Thanks - I wasn't familiar with rasphone. When I ran "rasphone -d MyVPN" it just popped up the dialog - it didn't dial automatically. Is there a way to dial automatically and skip the dialog? – Goyuix – 2015-03-28T16:09:55.603

2Read to the end of my post... in vpn properties->options you can disable the password dialog. – Jules – 2015-04-07T22:08:16.630

Once that box is unchecked for "Prompt for name.." both rasphone and rasdial appear to work as desired. Thanks! – Goyuix – 2015-04-08T15:31:56.233

rasphone -d "VPNCONNECTION" when Options are set as described works for me. For some reason rasdial won't use my cached credentials. I'm off & running with rasphone, so I'm happy. Thanks. – rich p – 2015-11-19T16:40:54.553

3

Create a .bat file with following command:

%windir%\system32\rasdial.exe "VPN NAME" /DOMAIN:

"VPN Name" would be the VPN connection name that you have given under Networking and Sharing Center. Quotes are required.

UserID and Password are required even if you have set the option to save your credentials.

Once the batch file is created you can assign a keyboard shortcut for instant access.

For disconnection, create another batch file with below command:

%windir%\system32\rasdial.exe "VPN NAME" /DISCONNECT

humanfly

Posted 2010-02-09T01:30:42.780

Reputation: 531

0

To connect to VPN without user interaction and to avoid write down the password in the batch file you can use ...

rasphone -d VPNname

... and remove "Prompt for Username and password" dialog with this answer ... https://superuser.com/a/1027290/418793

hoggar

Posted 2010-02-09T01:30:42.780

Reputation: 143

Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.

– DavidPostill – 2018-06-12T17:38:22.853

0

connect:

rasdial EntryName Username Password

disconnect:

rasdial EntryName /disconnect

EnteryName is name of your VPN connection

Many Dollars

Posted 2010-02-09T01:30:42.780

Reputation: 137

-3

Once you've saved the credentials, go into VPN properties-->options and uncheck "Prompt for name and password, certificate, etc." and you're good to go!

William

Posted 2010-02-09T01:30:42.780

Reputation: 1

Even with checking that option rasdial.exe does not use the stored credential. – Goyuix – 2010-07-29T14:12:59.150

The Op is not asking about how to avoid entering credentials into the connection window, rather how to avoid it all together! – JL. – 2010-08-16T20:31:10.327