11

guys.

I want to use the windows RASDIAL in my app to connect to a VPN.

I'm using this cmd command:

rasdial a-1 username pass

I just want to know, how to save password in this command for the next connects?

Thanks.

Mostafa Farzán
  • 899
  • 2
  • 11
  • 30

3 Answers3

8

Probably the OP already solve the problem (asked 4 years ago), but rasdial can't save the password. But you can use your stored credentials in Windows with rasphone. Remember to uncheck "Prompt for name and password, certificate, etc." in the connection properties to skip the dialog.

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."

https://superuser.com/a/894969/27235

Community
  • 1
  • 1
Dudaskank
  • 278
  • 4
  • 10
5

In Windows 10, rasphone will always prompt for credentials (Option to skip this step is gone. Thanks, Microsoft!). But I was able to use my saved password with rasdial by using EAP authentication:

Without EAP, MS-CHAP v2 does not work.

Now I can just execute rasdial VpnName, and it uses my saved password.

Eugene
  • 179
  • 2
  • 7
  • How to add user and pass into the rasphone.pbk? – Hrvoje Batrnek Nov 22 '18 at 11:53
  • 2
    I hit the same issue with Windows 10, but it seems you can edit a file to prevent the password dialog from popping up: Change `PreviewUserPw=1` to `PreviewUserPw=0` for your VPN connection in the %APPDATA%\Microsoft\Network\Connections\Pbk\rasphone.pbk file Read more here: https://superuser.com/a/1027290/282850 – Jervelund May 25 '19 at 21:01
3

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
  • 3,699
  • 5
  • 31
  • 41