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.

Shiftkey Avatar

Published by

Categories:

29 reacties op “Quickly connect to a VPN on Windows 10”

  1. […] I wrote about a trick to make Windows 10 connect to a VPN with a single action (double-click) instead of three or more. I recently found that this trick had a limitation: it only […]

  2. cactuscraig Avatar

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

  3. Shiftkey Avatar

    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 Avatar
    SirPlus

    rasdial “My VPN connection name here” /Disconnect

    Will Disconnect

  5. Petr Avatar
    Petr

    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

    1. Shiftkey Avatar

      Hi Petr,
      Thanks, that is a really cool trick! Works great.

  6. gtwengenharia Avatar

    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 Avatar
    Johan

    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?

    1. Shiftkey Avatar

      Hi Johan, I may have experienced the same issue as you have. Try my follow-up article:

      Quickly connect to a VPN on Windows 10 (revisited)


      Did that solve the issue for you? It worked for me.

      1. Johan Avatar
        Johan

        Hello Shiftkey, It does the trick, but in the dialog window you have to confirm, haha, stil one click too many right?

      2. René Avatar
        René

        Working nicely, putting it together with Petr’s reaction:

        @echo off
        ipconfig|find/i “MYCONN” && rasphone -h “MYCONN” || rasphone -d “MYCONN”

      3. Robert Avatar
        Robert

        Rene,
        That didn’t work for disconnecting for me.. I get a dial up networking command line information popup.. Any ideas?

    1. Shiftkey Avatar

      Hi Joelabine,
      Thanks for the link, I’ll give that a try.

  8. LRB Avatar

    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. SQL Duck (@SQLDuck) Avatar

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

  10. Nass Avatar
    Nass

    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. Jon Slack-Smith Avatar

    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. Marcin Gosiewski Avatar

    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.

    1. Shiftkey Avatar

      Hi Marcin,
      That sounds like a cool trick! I’ll give it a try.

      I must say I was a bit disappointed that the Anniversary Update has not improved this UI.

    2. Arnolddus Avatar
      Arnolddus

      PERFECT, works great here, no more workarounds ( instead of this one 😉 )

    3. waldyr Avatar
      waldyr

      I wish it didn’t have the fly out because I always found those annoying, but it’s much better than 5 clicks (if you were lucky) to connect and disconnect. Thanks for this work around.

  13. Rychlé vytáčení VPN spojení

    Do verze Windows 7 šlo k VPN připojit rychle z hla

  14. Wouter Avatar
    Wouter

    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.

    1. Marc Avatar
      Marc

      After applying the above edit, I made a shortcut to this rasphone.pbk file to my desktop and it works like a charm. It still requires two mouse clicks, but that’s also how the Cisco VPN client works, so I’m used to this. It even shows the right icon.

  15. Ed McCafferty Avatar
    Ed McCafferty

    You can bring back the W8.1 fly out instead…..This makes the old way to connect work again in Windows 10

    Step One: Open Regedit ( How did you know this wasn’t coming ha! ) (WIN+R and type regedit.exe)

    Step Two: Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control Panel\Settings\Network

    Step Three:Take ownership of the “Network” key/folder (right click, Permissions)

    Step Four: Select “Advanced” in the Permissions window

    Step Five: In the Advanced window, select “Change” where the owner field is (at the top of the window)

    Step Six: Type in your username and save your changes.

    Step Seven: Close the advanced window

    Step Eight: Now select “Administrators” in the security tab

    Step Nine: Make sure “Full control” is selected, then apply changes

    Step Ten: Now that’s done, double click “ReplaceVan

    Step Eleven: Change it’s value to 2

  16. audministrator Avatar

    Windows 7 and up has all you need, not commandline no free Tools needed…

    Go to the system32 directory, run the rasphone.exe. Pin it to your taksbar and there you go…

    Windows 10 – Quickly connect to a VPN

    You will have a nice little Gui to manage your VPN’s

    Enjoy !

Plaats een reactie