Skip to main content
jkoay
Staff & Editor
Staff & Editor
November 10, 2020

Technical Tip: Auto running script when connected to VPN

  • November 10, 2020
  • 0 replies
  • 25218 views

Description

 

This article describes the feature auto running script when connected to VPN.

 

This feature supports auto running a user-defined script after the configured VPN tunnel is connected or disconnected.
The script are batch scripts in Windows and shell scripts in macOS.

There are defined as part of a VPN tunnel configuration on EMS’s XML format FortiClient profile.
The profile is pushed down to FortiClient from EMS.
When FortiClient VPN tunnel is connected, script is executed.

Solution

 

In FortiClient EMS, access to Endpoint Profiles -> Remote Access Profile and Select <endpoint profile>.
On the top right corner, select 'XML tab'.

 

XML1.png

 

Then 'Edit' button.

 

XML3.png

 

Once finished editing the XML it is possible to save the changes with the 'Save' Button.

 

XML4.png
Select 'Edit' and search for the following <on_connect> tag.


XML2.png
The following is an example of configuring FortiClient to execute batch files when the VPN is connected:

 

<on_connect>
<script>
<os>windows</os>
<script>
<![CDATA[\\WIN-ADMIN\\netlogon\\logon.bat]]>
</script>
</script>
</on_connect>