How to Save Password in rasdial?

12,657

Solution 1

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

Solution 2

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.

Solution 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

Share:
12,657
Mostafa Farzán
Author by

Mostafa Farzán

Updated on July 24, 2022

Comments

  • Mostafa Farzán
    Mostafa Farzán almost 2 years

    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.

  • Hrvoje Batrnek
    Hrvoje Batrnek over 5 years
    How to add user and pass into the rasphone.pbk?
  • Jervelund
    Jervelund almost 5 years
    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: superuser.com/a/1027290/282850