cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
19548
Views
0
Helpful
1
Replies

Using AnyConnect VPNCLI via batch file.

rmenjivar1
Level 1
Level 1
Hi all,
I was trying previously to script a login using VPNCLI using VBScript. However, I've since simplified it by creating a batch file for this. Below, you'll see in the second line that I'm passing the contents of vpn_creds.txt (which contains only the username/password, one line each). However, as I scheduled this to run on a Windows Server 2012, I can't seem to get this to run while logged off. I've created a local admin account, set the task to run using this account, and checked off the "Run with highest privileges" option. All this to no avail. The task runs okay while I'm logged in. I confirm by checking the output file created in the fourth line of the batch file below; the 0's in the IP address is a redaction.
Also, I've tried using a network service account provided to me, but that didn't seem to work either. Any ideas? Thanks.

net start vpnagent
vpncli connect vpn-1.myvpnhost.com -s < C:\temp\vpn_creds.txt
ping 000.000.000.000 > C:\temp\ping_output.txt
vpncli disconnect
net stop vpnagent
P.S., seems to work ok when I schedule this on my machine, and not the server.
P.S. #2, my use of net start/stop is due to the occasional message I get:
 ">> error: Connect not available. Another AnyConnect application is running or this functionality was not requested by this application."
1 Reply 1

itservis11
Level 1
Level 1

you have to close anyconnect gui and then try connect again, this helped me