Run FortiClient SSL VPN from CLI and Scripts
This article describes how to use the FortiClient SSL VPN from the Windows command line, and apply from batch scripts. The FortiClient, available for FortiGate for all known operating systems, can be downloaded from the Fortinet Support section. In addition to the FortiClient 6.4.2.1580 for Windows used here, the FortiClientTools 6.0.9.0277 are also used.
After the FortiClient is installed, we leave the VPN configuration left blank. Now the FortiClientTools are unpacked into a directory, of interest is the folder contents of SSLVPNcmdline, here the file FortiSSLVPNclient.exe is to be found, along with the Microsoft Visual C++ Redistributable mfc140.dll, msvcp140.dll, vcruntime140.dll runtime components.
Contents of SSLVPNcmdline FortiClientTools_6.0.9.0277.zip.
Running FortiSSLVPNclient.exe opens the GUI.
We decide not to use the VPN connection profile stored in Settings, instead to connect from CLI with append parameters.
1 2 |
FortiSSLVPNclient connect -h 226.62.42.81:10443 -u homer:password123 -i -q -m |
It is now a good way to start the VPN connection with login and network drive mapping from the script, the following batch file should enable this.
1 2 3 4 5 6 7 |
@echo off START "" /I FortiSSLVPNclient connect -h 226.62.42.81:10443 -u homer:password123 -i -q -m timeout 10 net use * /delete /yes net use R: .10.10.10.10-data /user:homer password123 /persistent:no REM further instructions! |
With connect -h will connect to the VPN gateway, the IP address and the port number separated by a colon. The user -u who should log in to the gateway and the password after the colon. Cause timeout wait 10 seconds to VPN connection to be established before execute network drive mapping. The value may be reduced or it must be increased.
In the taskbar, the FortiSSLVPNclient icon, over which the context menu opens with a right click.
The VPN connection is disconnected with the following script.
1 2 3 |
@echo off START "" /I FortiSSLVPNclient disconnect |
FortiSSLVPNclient Command Line Usage
Usage: FortiSSLVPNclient.exe [options] [args]
Source link: Fortinet Knowledge Base