Run FortiClient SSL VPN Scripts from CLI
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, download from the Fortinet Support section. In addition to the FortiClient 184.108.40.2060 for Windows used here also the FortiClientTools 6.0.9.0277.
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.
FortiSSLVPNclient connect -h 220.127.116.11: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.
@echo off START "" /I FortiSSLVPNclient connect -h 18.104.22.168: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!
connect -h will connect to the VPN gateway, belong 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. With the 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 Icon FortiSSLVPNclient, over which the context menu opens with a right-click.
The VPN connection can be disconnected with the following script.
@echo off START "" /I FortiSSLVPNclient disconnect
FortiSSLVPNclient Command Line Usage
Usage: FortiSSLVPNclient.exe [options] [args]
Source link: Fortinet Knowledge Base