Windows – Single-Click to connet to VPN on Windows 10

internetnetworkingvpnwindows 10

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.

Best Answer

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.

Related Question