Quickly connect to a VPN on Windows 10

All-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. It will list all your VPN connections:

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.

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. It will list all your VPN connections.

Double-click the VPN connection you want. Done. No, this will open a new window, which lists all your VPN connections, again. (Huh?)

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.

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

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:

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

Advertenties

Share this:

Vind ik leuk:

Gerelateerd

Over ShiftkeyI 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.

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.

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?

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.

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.

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.