Connect with us

Hi, what are you looking for?

Internet

How to Automatically Connect to a VPN for Certain Apps in Windows 10

How to Automatically Connect to a VPN for Certain Apps in Windows 10

👨‍💻

With the PowerShell cmdlet for Windows 10, you can easily add apps to automatically launch the VPN connection when it is started. Automating this task means that you don’t even have to think about connecting to a VPN when using certain apps.

To take advantage of this functionality in PowerShell, you will first have to add a VPN service to your computer if you don’t already have one.

Related: How to connect to a VPN in Windows

How to add VPN Auto-Triggering

After setting up a VPN connection on Windows 10, you will need to open an elevated instance of PowerShell. To do this, click on the “Start” button, then type “Powershell”. Right-click on “Windows PowerShell”, then select “Run as administrator” from the menu.

Click Yes at the prompt that appears to allow access to your computer.

In the PowerShell window, type the following and replace And With the name of the VPN connection, and the file path of the application you want to use, respectively:

Add-VpnConnectionTriggerApplication -Name ““–ApplicationID”

Make sure to include quotes in the command.

Press Enter to run the command. PowerShell warns you that split tunneling is disabled by default. To continue, you must confirm and enable the feature before it will turn on automatically.

Type “Y” when the prompt appears, then press Enter again to quit.

You have to enable automatic split-tunneling of the trigger to connect to the VPN without human intervention.

Split tunneling prevents Windows from routing all network traffic through the VPN when the application launches it to start. Instead, it splits the traffic, and the data from the listed app will only flow through the VPN.

Type Set-VpnConnection -Name “-SplitTunneling $True in PowerShell and replace Name your VPN (again, keep the quotes around it), then press Enter.

Then, in case you accidentally close the app and you don’t want to end the connection, you can set a timeout buffer to restart the app.

Type Set-VpnConnection -Name “-IdleDisconnectSeconds in PowerShell and press Enter. replace On behalf of your contact and The number of seconds to wait for the connection to end.

Now, when you close the app, Windows 10 will wait seconds before it terminates the VPN connection. You can make this number as you like or omit this step completely.

How to find out which apps are automatically running a VPN

There are several ways you can check to see which apps you have set to start the VPN connection. You can either use a cmdlet inside PowerShell or edit the phonebook file in File Explorer.

Related: How is PowerShell different from Windows Command Prompt

If the VPN suddenly started and you are not sure why, you can use either of the following two methods to determine which application triggered it.

Using PowerShell Cmdlet

To use this method, click on the “Start” button and type “Powershell”. Right-click on “Windows PowerShell”, then select “Run as administrator” from the menu.

Click Yes at the prompt that appears to allow access to your computer.

In the PowerShell window, type the following command, but replace name your VPN connection, then press Enter:

Get-VpnConnectionTrigger -ConnectionName

In our example, the command retrieves the properties of the VPN connection “VPN Canada” and displays them below.

Using File Explorer

The other option is to track a dial-up phonebook file in File Explorer. You can open it in a text editor and see the list of apps running the VPN.

A phonebook file provides a standard way for Windows to collect and specify the information it needs to establish a remote access (RAS) connection. The file contains information such as IP addresses, ports, modem settings, and – the information we’re looking for – which applications are running the connection.

To get started, open File Explorer and paste the following directory into the address bar, but replace with the current user name, then press Enter:

C: Users AppData Roaming Microsoft Network Connections Pbk

Right-click on “rasphone.pbk”, then select the text editor in which you want to open the file.

This one file contains all the VPN connections on your computer, so if you have more than one VPN, you may have to sift through a lot to find the apps you want. Each application is stored within the “ClassicApplicationIDs” function as a direct path to the file.

Fortunately, if you don’t want to scroll to find every app, most text editors have a Search feature. Press Ctrl + F , type ClassicApplicationIds into the text field, then press Enter.

How to remove VPN Auto-Triggering

If you accidentally add the wrong app or you no longer want the VPN to run when certain apps are running, you can remove it using a similar cmdlet in PowerShell.

Related: Geek School: Learn to use cmdlets in PowerShell

To remove VPN autorun, click the Start button, then type “Powershell.” Right-click on “Windows PowerShell”, then select “Run as administrator” from the menu.

Click Yes at the prompt that appears to allow access to your computer.

In the PowerShell window, type the following, but replace And With the name of your VPN connection and the path to the application, respectively:

Remove-VpnConnectionTriggerApplication-Name”“–ApplicationID”

PowerShell prompts you to confirm that you want to remove the app from the autorun list. Type “Y” and press Enter.

Repeat this step for each app you want to remove from the list.


Now, when you run the applications you selected, Windows will start the VPN connection and send traffic through it – no third-party software is required.

[ad_1]
Don’t forget to share this post with friends !

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related

Internet

AnyConnect certificate-based authentication. Cisco community 👨‍💻 The information in this document is based on the following software and hardware versions: ASA 5510 running software...

Internet

ITProPortal . Portal 👨‍💻 We live in a dynamic moment in terms of technology. Even criminals are becoming more technically savvy and are using...

Internet

Top 5 Free AV Packages – 👌 Bitdefender Antivirus Free Edition best interface Positives Works on Windows 7 and 8.1 Very easy to use...

Internet

Download antivirus for free. Best antivirus protection 👨‍💻 Protecting your identity, banking information and privacy Cybercriminals want your credit card details, passwords and other...