How to automatically connect VPN to specific apps on Windows 10

With Windows 10 PowerShell (cmdlets), you can easily add applications to automatically activate VPN connections when they launch. Automating this task means you won't have to worry about connecting to a VPN when using certain apps.

To take advantage of this functionality in PowerShell, you will first need to add a VPN service to your computer if you don't already have one. Check out the article: How to create a VPN on Windows 10 for how to do it.

How to add automatic VPN activation feature

After establishing a VPN connection on Windows 10, you will need to open PowerShell as an administrator.

How to automatically connect VPN to specific apps on Windows 10 Picture 1
Open PowerShell as admin

Click Yes right in the prompt that appears to allow access to the computer.

In the PowerShell window, enter the following command, then replace and with the name of the VPN connection, plus the file path to the application you want to use, respectively:

 Add-VpnConnectionTriggerApplication -Name "" –ApplicationID "" 

Note include the quotes in the command.

Hit Enter to run the command. PowerShell warns you that Split tunneling is disabled by default. To continue, you must confirm and enable this feature first.

Type Y when the prompt appears, then press Enter again to finish.

How to automatically connect VPN to specific apps on Windows 10 Picture 2
Type Y when the prompt appears

You must enable Split tunneling to enable automatic connection to the VPN without human intervention.

Split tunneling prevents Windows from routing all network traffic through the VPN, when the application activates it to start. Instead, split tunneling divides the traffic and only data from the listed application is transferred over the VPN.

Enter the following command in PowerShell:

 Set-VpnConnection -Name "" -SplitTunneling $True 

. and replace with the name of your VPN (note the quotation marks), then press Enter .

Next, in case you accidentally close the application and do not want the connection to terminate, you can set the timeout buffer to restart the application.

Import:

 Set-VpnConnection -Name "" -IdleDisconnectSeconds 

. go to PowerShell and press Enter . Replace with your connection name and with the number of seconds to wait until the connection is terminated.

Now, when the application closes, Windows will wait 10 seconds before terminating the VPN connection. You can change this number as you like or skip this step altogether.

How to see which apps automatically activate VPN

There are several ways you can check to see which applications have been installed to automatically activate the VPN connection. You can use a command in PowerShell or edit the phonebook file in File Explorer.

If the VPN suddenly starts and you're not sure why, you can use one of the following methods to determine which application has enabled it.

Use a PowerShell cmdlet

To use this method, click the Start button and enter Powershell. Right-click on Windows PowerShell and then select Run as Administrator from the menu.

Click Yes right in the prompt that appears to allow access to the computer.

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

 Get-VpnConnectionTrigger -ConnectionName 

Use File Explorer

Another option is to track dial-up phonebook files in File Explorer. You can open it in a text editor and see the list of VPN enabled apps.

The phonebook file provides a standard way for Windows to collect and specify the information needed for setting up Remote Access Connection (RAS). This file contains information such as IP address, port, modem settings and information you are looking for about applications that can trigger connections.

To get started, open File Explorer and paste the following folder in the address bar, but replace it with the current username, then press Enter :

 C:UsersAppDataRoamingMicrosoftNetworkConnectionsPbk 

Right-click on 'rasphone.pbk' and then select the text editor in which you want to open the file.

How to automatically connect VPN to specific apps on Windows 10 Picture 3
Right click on 'rasphone.pbk'

This file contains all the VPN connections on your computer, so if you have multiple VPNs, you may have to sift through a lot to find the applications you want. Each application is stored in the 'ClassicApplicationIDs' function as the direct file path.

Fortunately, if you don't want to scroll through each application, most text editors have a Find feature. Press Ctrl + F , type 'ClassicApplicationIds' into the text field, then press Enter .

How to automatically connect VPN to specific apps on Windows 10 Picture 4
Enter 'ClassicApplicationIds' in the text field

How to remove the automatic VPN activation feature

If you accidentally add a wrong application or no longer want a VPN to activate when launching specific applications, you can delete them using a similar cmdlet in PowerShell.

To remove the automatic VPN activation feature, open Powershell with admin rights.

Click Yes in the prompt that appears to allow access to the computer.

In the PowerShell window, enter the following, but replace and with the name of the VPN connection plus the path to the corresponding application:

 Remove-VpnConnectionTriggerApplication -Name "" –ApplicationID "" 

PowerShell prompts you to confirm deletion of the application from the automatic activation list. Type Y and press Enter .

Repeat this step for every application you want to remove from the list.

4 ★ | 35 Vote

May be interested

  • How to disable autorun apps when starting MacBookHow to disable autorun apps when starting MacBook
    it's a fact that many software programs are set to automatically boot with macbooks by default. that is, they will also start automatically when the user starts the computer.
  • How to lock Windows PC after automatic loginHow to lock Windows PC after automatic login
    automatic sign-in is handy because you can launch the pc program when it starts or let your pc boot automatically at specific times. to improve security, you can let windows 10 automatically lock and ask for a password after you sign in automatically.
  • How to enable / disable the Archive Apps feature in Windows 10How to enable / disable the Archive Apps feature in Windows 10
    starting with windows 10 build 20201, a new archive apps feature has been added. this guide will show you how to enable or disable the archive apps feature for your account or specific accounts in windows 10.
  • The trick prevents Windows from automatically updating specific driversThe trick prevents Windows from automatically updating specific drivers
    on windows operating systems, especially windows 10 usually automatically installs driver updates for hardware even if required or not required. if you do not want to automatically update dirver, you can proceed to prevent windows from automatically updating the driver. if you are using windows pro or enterprise version, you can use group policy editor to prevent windows from automatically updating drivers.
  • How to install Miracast Connect app on Windows 10How to install Miracast Connect app on Windows 10
    previously, the connect app was pre-installed by default, but starting with windows 10 version 2004, it is an optional feature that you have to manually install to connect to compatible devices. miracast.
  • 11 Useful Windows Apps That Don't Come Pre-Installed11 Useful Windows Apps That Don't Come Pre-Installed
    there are a number of handy windows apps that most users would probably enjoy if they were part of the windows experience from the start.
  • 12 Apps Windows 11 Users Should Install on Their New PC12 Apps Windows 11 Users Should Install on Their New PC
    here are 11 apps you should have on microsoft's new operating system. these apps improve on existing features or add what windows 11 lacks (and they work just as well on windows 10).
  • How to Connect to WiFi in Windows 10How to Connect to WiFi in Windows 10
    wi-fi has been around for a while now, enabling us to connect to our favorite websites and chat while playing games with our friends. windows 10's brand new interface changes how you connect to wireless networks. luckily, connecting to...
  • Instructions for scheduling a Windows 10 computer shutdownInstructions for scheduling a Windows 10 computer shutdown
    turning off your windows computer simply means you work with the power key. however, if you are in the habit of working late at night and often forget to turn off your computer, you can set the automatic shutdown schedule at a specific time in advance.
  • How to login automatically to Windows 8How to login automatically to Windows 8
    today we will guide you to set up customizations for windows 8 to log in automatically every time you start windows, making you ready to work immediately after turning on your computer easily.