connect with vpnclient.exe from scheduled task

2

I have a set of scheduled tasks I've inherited, which require a vpn connection. Right now they only work when a user is logged in interactively.

When I launch the connection from a script (.bat/.ps1), the GUI login prompt displays (which it shouldn't) and requires the user to click 'Connect'. If the bat is run from a scheduled job, the job just hangs forever, presumably waiting on input to a form that isn't being displayed. Here is my launch command:

"%ProgramFiles%\Cisco Systems\VPN Client\vpnclient.exe" connect <profile> user <username> pwd <password>

The parameters for the connection have been tested interactively and work fine.

I've confirmed the command syntax with this page, and I have tried the cliauth parameter, but without luck. I've also confirmed that there is not an old password saved in the profile (.pcf) file.

So, how can I make the client connect without any interaction from a user?

Additional info: the batch file we schedule looks like this:

CALL "F:\VPN\Start_VPN_Connection.bat"
CALL "F:\Scripts\FTPSync.bat"
CALL "F:\VPN\End_VPN_Connection.bat"

and the Start_VPN_Connection.bat is exactly as shown above, but with the security credentials. The FTPSynch.bat runs a winscp synch, but the script only gets that far if we connect interactively.

Frank Thomas

Posted 2014-09-05T14:21:06.197

Reputation: 29 039

So your running the scheduled task as a BAT file why not run the command directly from the scheduled task instead of using a bat file? Also what else is in the BAT file do you have any ECHO set, etc.? – CharlesH – 2014-09-05T15:13:16.643

well, the batch file connects and then kicks off another series of operations, and then ends the VPN connection. since we don't know how long the connection will be used, and because the subsequent jobs must never run when the connection has not been established, we kind of need to keep them together. I've updated my question with some additional information about the scripts. they do not set or use echo directly, though the vpnclient.exe does print to stdout. – Frank Thomas – 2014-09-05T15:48:30.707

Thanks Frank, I would still be interested to know if the command works running directly from a scheduled task without the BAT files purely to rule it out of the troubleshooting steps... – CharlesH – 2014-09-05T15:50:33.443

When I put the connect command in the task scheduler, seperating the parameters, the job runs without error, but no connection is made. if I put the params on the command itself, it fails. When run from the batch file interactively, everything works (but the gui displays and you have to click connect). – Frank Thomas – 2014-09-05T16:14:40.407

Hmm something doesn't sound right.. sadly I haven't got a cisco VPN to test with at the moment however when I run a test (knowing it will fail) I never get a gui unless I run VPNGUI.. what happens if you go to the direction and double click on VPNclient no GUI displays? – CharlesH – 2014-09-06T07:52:42.700

No answers