Hello everyone!
Hoping you are doing well and having a great day.
I am developing a .bat script for the recreation of VPN site for VPN clients of one of our customers.
I am basing it on commands from the Remote Access documentation in the CLI section:
https://sc1.checkpoint.com/documents/RemoteAccessClients_forWindows_AdminGuide/Content/Topics-RA-VPN...
For now, I have the following for my script:
- @echo off
- cd C:\Program Files (x86)\CheckPoint\Endpoint Connect\
- trac.exe ver
- trac.exe disconnect
- trac.exe delete -s vpn.company.com
- trac.exe create -s vpn.company.com -di vpn.company.com -a username-password -lo Standard
The script does the following:
- @echo off to ensure that the script commands are not displayed in the cmd console.
- Change to the directory where trac.exe is located.
- Show client version
- Disconnect client
- Delete current VPN site
- Recreate current VPN site with username and password as authentication method
The specific requirement of our customer is that, the domain username of the PC is extracted and defined in a variable in order to be able to execute the following command and that the username is the domain user:
trac.exe userpass -s <sitename> -u <username> -p <password>
I see that if I run the following in CMD, I can see my domain username based on a Windows system environment variable:
echo %USERNAME%
Then, I also see that if I run the following, I can save %USERNAME% in a variable called USER:
set USER=%USERNAME%
However, when I try to use this variable in the command trac.exe:
trac.exe userpass -s vpn.company.com -u %USER%
I see the following error:

I would like to know if there is a way to extract this domain username from a PC to configure it by “default” once I run my script to recreate the VPN site.
And that once the VPN client is reconfigured, the user can see his domain user so that he can just enter his passwords and then proceed with the VPN authentication/authorization using an LDAP with Identity Awareness. (This last one is already configured, I just want to see if the domain user can be configured so that the user just comes in and enters his password).
I know this is maybe something more related to .bat scripting but I hope you can help me.
Greetings!!