Single-Click to connet to VPN on Windows 10

6

6

I'm creating a batch file to connect to VPN on Windows 10 by a Single-Click. The VPN is using PPTP. Below is the command I've tried and different problems I faced:

1) rasphone -d "VPN NAME"**

Problem: A dialog popped up and ask for confirmation. How can I make it dial automatically without such dialog? I see in this thread (Windows 7 default VPN - Single Click to Connect) and people said we can go into the option tab of the properties for the VPN connection and uncheck "Prompt for name and password, certificate, etc.". However, I can't find such option.

2) rasdial "VPN NAME"

Problem: It doesn't work. VPN not connected. A error message was shown telling me the login credential is not correct

3) rasdial.exe "VPN NAME" "USERNAME" "PASSWORD"

Problem: Even it is worked, but I don't want to type my password in such command as it may have some security problem. I've already saved my credentials in the VPN property, how can I ask rasdial to use those credentials automatically?

Thanks so much.

Kit Ng

Posted 2016-01-16T17:47:12.640

Reputation: 161

I was looking for this for a while and caved to using option 3 (Which does work) as nobody else has physical access to my machine. I don't like it either, it seems an oversight that the checkbox for "Prompt for name and password, certificate, etc." has been removed in Windows 10. – Jonno – 2016-01-16T18:10:33.640

Pretty much everything useful has been removed in W10.... – Moab – 2016-01-16T18:18:22.123

Jonno, you are right, I compared the old VPN property screen with that of Windows 10, and obviously the useful option of "Prompt for name and password, certificate, etc." is just removed. Really having no idea why such important option can be removed, maybe anybody else can have a workaround by cmd or other methods? – Kit Ng – 2016-01-16T18:30:39.413

@KitNg Fixed it! – Jonno – 2016-01-16T18:47:17.870

Answers

12

I've solved it without need to mess around, so you can use option 1 since Windows 10 removed this checkbox:

  1. Open %APPDATA%\Microsoft\Network\Connections\Pbk\rasphone.pbk in a text editor (Back it up first!)
  2. Find [YOURVPNNAME]
  3. Find PreviewUserPw=1 - Change it to PreviewUserPw=0
  4. Save the file

Option 1 should now be working without a prompt.

Jonno

Posted 2016-01-16T17:47:12.640

Reputation: 18 756

Nice solution. Actually I haven't tried it (because I usually not dare to edit any raw codes of a system file...LOL), but I think this solution makes sense. The only concern is if this mod may cause any side effect? As it is not officially supported by the system itself. – Kit Ng – 2016-01-27T20:37:47.467

@KitNg I don't think there will be any, it's just a plain text file, like a .ini file. All the GUI interface does is change then I'm the same way, and it's so tiny you can just back it up in the same folder in case anything goes wrong. To be honest, if anything did go wrong, just delete it and re add your VPN again (it automatically generates again). Strangely this file hasn't changed in any recent generation of Windows, so I can't understand why Windows 10 lost the checkboxes, because it still uses their values to work! – Jonno – 2016-01-28T03:11:08.363

On Windows 10 works like a charm! – hoggar – 2018-06-11T23:12:25.350

Thank you I needed this! – ZaxLofful – 2019-05-09T18:31:34.450

This is so bizarre. Even after setting PreviewUserPw=0. rasphone -d "VPN NAME" opens the login window. – JohnnyO – 2019-07-31T20:43:49.493

@JohnnyO It's entirely possible the behaviour has changed, as this workaround was found about 3.5 years ago. Unfortunately I'm not in a position to test it at the moment, sorry. – Jonno – 2019-08-01T21:03:29.330