Quickly connect to a VPN on Windows 10

vpn11All-in-all I am very happy with my upgrade from Windows 7 to 10. The procedure was smooth and almost (more on that later) everything still worked like a charm, out-of-the-box, despite having lots of not-so-obvious software on the machine. (Comes with the job as a developer, I guess.)

However, one minor thing very soon annoyed me on Win10 and that was the crappy user experience for connecting to a VPN, despite that shiny new VPN button in the new Action center (btw, action center tip: use WinKey+A), which in itself looked like good idea. I have quite a list of VPN’s defined, first of all to connect to my own office while on the road, and many others to connect to my client’s networks to diagnose problems or perform software updates. So allow me to first complain a bit about what I think is wrong with it, before presenting a workaround (or solution if you will) below.

Compare the following experience on Windows 7 versus that of Windows 10 (or Windows 8).

Windows 7

Easy way to connect

  • Click the network icon in the system tray.vpn1 It will list all your VPN connections:
    vpn2
  • Double-click the VPN connection you want. Done!

Even easier way to connect

Create a desktop shortcut to the VPN by going to the Network Adapter Settings and dragging the VPN icon onto the desktop.

vpn3

  • Double-click the VPN icon on your desktop. Done!

Windows 10

Easy way to connect?

At first, it appears as if you can still do the same as you were used to.

  • Click the network icon in the system tray. vpn4 It will list all your VPN connections.
    vpn5
  • Double-click the VPN connection you want. Done. No, this will open a new window, which lists all your VPN connections, again. (Huh?)
    vpn6
  • Find the same VPN you double-clicked before in this list. Double-click it. Done. No, double-clicking doesn’t work here. Single-click it.
    vpn7
  • The VPN item expands, now showing a Connect button. Click that.
  • The VPN connects. Click the X to close this window.

That is five actions instead of two.

Even easier way to connect?

It gets even worse here.

That desktop shortcut I created while on 7 was migrated to Windows 10 perfectly fine, so I figured let’s keep using that.

  • Double-click the VPN icon on your desktop. Done. No! This also opens this dreaded window where I have to select the same VPN from the list, again, and perform three more unnecessary clicks where a simple double-click should have sufficed.

That is four actions instead of one.

I find it hard to believe there was no usability expert that has noticed this. It is plain silly UI: why list the VPN’s first from the system tray and allow you to click them, only to make you find and click the same one again from a new window? It makes that first list completely senseless.

Personally, it appears to me like a simple oversight that may be fixed in a future update. vpn9For example: the procedure to create a shortcut to a VPN by dragging it from the adapter list to your desktop still works in Windows 10. This shortcut then even features a context menu items that says Connect / Disconnect. That would make you think it would do precisely that: connect to that VPN. But it doesn’t. It just opens the VPN list window. Why?

The workaround

Fortunately, there is a way to script yourself around this. Enter the rasdial command! (Which also exists on Windows 7 BTW.)

  • Create a batch file on a convenient location and edit it.
  • Paste the following lines (note the use of quotes if there are spaces in the VPN name). The first line is optional.
@echo off
rasdial "My VPN connection name here"
  • Save
  • Create a shortcut to this batch file on your desktop.
  • Optionally give it a nice icon. I took the 115th one from %systemroot%\system32\imageres.dll.
    vpn10

Now, if you double-click the icon on the desktop, you get a brief command window instead of a gui, but the message is the same:

vpn8

And you just connected to your VPN with a only one double-click. Sigh.

Advertisements

Over Shiftkey
I am Maarten, owner of and chief software developer for Shiftkey software development from The Netherlands. I will be writing mainly about things I run into when programming in C# or Delphi.

25 Responses to Quickly connect to a VPN on Windows 10

  1. Pingback: Quickly connect to a VPN on Windows 10 (revisited) | Shiftkey Software Blog

  2. cactuscraig zegt:

    so now I need 2 icons – one to connect and 1 to disconnect!

  3. Shiftkey zegt:

    Yes, that’s true. Although I guess one could attempt to script it into one batch file, depending on the response of rasdial (it says ‘already connected to …’ if you run it for an already connected vpn), but that was not worth the effort for me. I often need to connect to a vpn but quite less often need to explicitly disconnect from it while keeping on working. Most of the time I just shut down my laptop, which also effectively disconnects the vpn. But that may be different for your situation.

  4. SirPlus zegt:

    rasdial “My VPN connection name here” /Disconnect

    Will Disconnect

  5. Petr zegt:

    Thanks for the Article i have found this one. It will connect and disconnect 😀

    @echo off
    ipconfig|find/i “MYCON” && rasdial “MYCON” /disconnect || rasdial “MYCON”

    https://stackoverflow.com/questions/31990775/batch-file-to-connect-and-disconnect-from-vpn-connection/32000249#32000249

  6. Veeeery nice tip! But really, the Microsoft interface designer deserves an award.
    I do not understand how they could complicate something so simple. Unbelievable.

  7. Johan zegt:

    I have configured myVPN and I ran the following in CMD,

    rasdial “myVPN”

    Response:

    Connecting to myVPN…
    Verifying username and password…
    Connecting to myVPN…
    Connecting to myVPN…
    Verifying username and password…

    Remote Access error 691 – The remote connection was denied because the user name and password combination you provided is not recognized, or the selected authentication protocol is not permitted on the remote access server.

    But when I connect it in the windows interface it connects perfectly fine… what am I doing wrong?

  8. LRB zegt:

    What worked for me was to have the initial connection name in lowercase and in quotes and to drop the quotes from the other connection names, so:

    ipconfig|find/i “oracle” && rasdial ORACLE /disconnect || rasdial ORACLE

    The ‘find’ required the quote marks, but rasdial doesn’t in my case.

  9. Thanks, works great! Glad I wasn’t the only one who thought this was a bizarre UI update.

  10. Nass zegt:

    Really nice trick!
    Think to put “pause” at the end of your .bat files in case if you want to see what’s happenning in the background..

  11. Thank you for all this information. Every version of Windows seems to have some function hidden a menu level deeper than it was last version. This was the one annoying me most about 10.

  12. There is actually a way better and cleaner way to do this. Actually you CAN revert the silly misdesign of Windows 10 network connection procedure back to Windows 7/8 style. The old style networks flyout is still built into Windows and you can reveal it and estore the better one-click behavior of the networks flyout.

    The procedure requires changing one single Registry key however to do this you have to grant yourself permissions to do this so the whole procedure is:

    Open regedit (WIN+R and type regedit.exe)
    Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control Panel\Settings\Network
    Take ownership of the “Network” key/folder (right click, Permissions)
    Select “Advanced” in the Permissions window
    In the Advanced window, select “Change” where the owner field is (at the top of the window)
    Type in your username and save your changes.
    Close the advanced window
    Now select “Administrators” in the security tab
    Make sure “Full control” is selected, then apply changes
    Now that’s done, double click “ReplaceVan”
    Change it’s value to 2

    Voillla!
    You can experiment with different values of ‘ReplaceVan’. But the value 2 is what we need.

  13. Pingback: Confluence: Ostatní

  14. Wouter zegt:

    When using rasphone instead of rasdial, you can connect with just one click.

    You can disable the “Username/Password dialog box” by doing the following:
    Step 1: Open this file in notepad.exe but make first a backup:
    %APPDATA%\Microsoft\Network\Connections\Pbk\rasphone.pbk
    Step 2: Find in the textfile [YourVPNName]
    Step 3: Then find PreviewUserPw=1 under [YourVPNName] ==> Change it to PreviewUserPw=0 Step 4: Save the file

    You can now use rasphone -d “YourVPNName” without a password promt and without having your password in a batch file/the executed command, Windows wil use cached credentials. This works in all Windows versions, including 8/8.1/10.

    Make a desktop shortcut to rasphone -d “YourVPNName” and give it a name. Double click the shortcut and VPN connect.

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

%d bloggers liken dit: