قالب وردپرس درنا توس
Home / Tips and Tricks / How to automatically connect to a VPN for specific apps in Windows 10

How to automatically connect to a VPN for specific apps in Windows 10



  Windows logo

With the PowerShell cmdlet of Windows 10 you can easily add applications to automatically activate a VPN connection when they are started. If you automate this task, 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 must first add a VPN service to your computer if you do not have one yet.

RELATED: Connecting to a VPN in Windows

How to add VPN Auto-Triggering

After setting up a VPN connection on Windows 1

0, you need an elevated instance of Open PowerShell. To do this, click the Start button and then type "Powershell". Right click on "Windows PowerShell" and then select "Run as administrator" from the menu.

 Type

Click "Yes" in 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 file path to the application that you want to use:

  Add-VpnConnectionTriggerApplication -Name " "–ApplicationID"  "

<img class =" alignnone wp-image-529353 size-full "data-pagespeed-lazy -src =" https://www.howtogeek.com/wp-content/ uploads / 2020/01 / 2020-01-24_12h16_29.png "alt =" The "Add-VpnConnectionTriggerApplication -Name" "–ApplicationID" "command in a PowerShell window. "width =" 650 "height =" 115 "src =" / pagespeed_static / 1.JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); "onerror =" this.onerror = null; pagespeed.lazyLoadImagesibleAndLayImisibleBelaybeVis (this); "/>

Be sure to include the quotes in the command.

Press Enter to execute the command. PowerShell warns you that split tunneling is disabled by default. To continue, confirm and enable the function before it was automatically activated

When the prompt appears, type "Y", and then press Enter again to complete.

 The

You must enable split tunneling for the auto-trigger to connect to the VPN without human intervention.

Split tunneling prevents Windows from routing all network traffic through the VPN when the application starts it, instead splitting the traffic, and only the data of the mentioned application will flow through the VPN.

Type Set-VpnConnection -Name "" -SplitTunneling $ True in PowerShell and replace with the name of you w VPN (again, keep the quotation marks around it) and then press Enter. [19659003] <img class = "alignnone wp-image-529424 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2020/01/x2020-01 -24_12h43_34 .png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.udw5qPM6A-.png "alt =" The "Set-VpnConnection -Name" "-SplitTunneling $ True" command in a PowerShell window. "Width =" 650 "height =" 136 "src =" / pagespeed_static / 1.JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this) ; "onerror =" this.onerror = null; pagespeed.lazyLoadImagesibleAndLayImisibleBndLayImisibleBelaybeVis (this); "/>

Next, if you accidentally close the application and do not want the connection to be broken, you can set a timeout buffer to restart the app.

Type Set -VpnConnection -Name "" -IdleDisconnectSeconds in PowerShell and press Enter. Replace with the name of your connection and with the number of seconds to wait until the connection is broken. [19659003] <img class = "alignnone wp-image-529496 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2020/01/x2020-01 – 24_13h00_58.png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.6fNdVKgYes.png "alt =" The "Set-VpnConnection -Name" "-IdleDisconnectSeconds " command in a PowerShell window. "Width =" 650 "height =" 100 "src =" / pagespeed_static / 1.JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this) ; "onerror =" this.onerror = null; pagespeed.lazyLoadImagesibleAbayVisIbayVisIvay (this); "/>

Now, when the application is closed, Windows waits 10 seconds before the VPN connection is terminated. You can make this number whatever you want or omit this step altogether.

How to see which Applications Activate a VPN automatically

There are a few ways you can check which applications you have set to activate the start of a VPN connection. You can use a cmdlet in PowerShell or edit the phonebook file in Explorer.

RELATED: How PowerShell differs from the Windows command prompt

If the VPN suddenly starts and you are unsure why, you can use one of the following methods to locate which application it has activated.

Using a PowerShell Cmdlet

To use his method, click the Start button and type "Powershell". Right click on "Windows PowerShell" and then select "Run as administrator" from the menu.

 Type

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

In the PowerShell window, type the following command, but replace <VPNConnection > with the name of your VPN connection and then press Enter: [19659013] Get-VpnConnectionTrigger -ConnectionName [19659014] <img class = "alignnone wp-image-533207 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content / uploads / 2020/01 / x2020-01- 25_11h13_08.png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.4NQPAl34YM.png "alt =" The command "Get-VpnConnectionTrigger -ConnectionName "in a PowerShell window." width = "645" height = "171" src = "/ pagespeed_static / 1.JiBnMqyl6S.gif" onload = "pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this);" onerror = "this.onerror = null; pagespeed.lazyLoadImagesibleAndLayImisibleBelaybeVis (this); "/>

In our example, the command retrieved the trigger properties of the VPN connection" VPN Canada "and displayed it below.

Use File Explorer

The other option is to find the dial-up directory file in Explorer. You can open it in a text editor and view the list of applications that activate the VPN.

A phonebook file provides a standard way for Windows to collect and specify the information it needs to establish a Remote Access Connection (RAS). The file contains information such as IP addresses, ports, modem settings and – the information we are looking for – applications that activate the connection.

To start, open Explorer and paste the following directory in the address bar, but replace with the current username and press Enter:

  C:  Users    AppData  Roaming  Microsoft  Network  Connections  Pbk 

 Paste the file path in the address bar.

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

 Right-click

This one file contains all VPN connections on your computer, so if you have more than one VPN, you may need to search a lot to find the applications you want. Each application is stored under the "ClassicApplicationIDs" function as the direct file path.

 A list of

Fortunately, if you don't want to scroll to find each app, most text editors have a search function. Press Ctrl + F, type "ClassicApplicationIds" in the text field, and then press Enter.

Remove VPN Auto-Triggering

If you accidentally add the wrong application or no longer have the VPN to activate when you launch specific apps, you can remove them with a similar cmdlet in PowerShell.

RELATED: Geek School: learning to use Cmdlets in PowerShell

automatically remove VPN activation, click the Start button and type "Powershell". Right click on "Windows PowerShell" and then select "Run as administrator" from the menu.

 Type [19659003] Click "Yes" in 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 will ask you to confirm that you want to remove the application from the auto-trigger list. Type "Y" and press Enter.

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


Windows starts a VPN connection when you start the specified applications. and direct their traffic through it – no third-party software required.




Source link