I have a batch that wraps AnyConnect Mobility Client CLI (vpncli.exe) and asks username and password to later handle them to vpncli.

Simplified code:

set /p user_id=Username:
set /p pwd=Password:
echo %user_id%> c:\temp\configvpn.txt
echo %pwd%>> c:\temp\configvpn.txt

set install_dir="C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client"

%install_dir%\vpncli.exe connect myvpn.mydomain.TLD -s < c:\temp\configvpn.txt

net use h: \\fileserver\sharename /user:domain\%user_id% %pwd%

The last line it's why we do it this way: to not prompt user password twice (first for connecting VPN and second to map network drive)

For security reasons I'm improving the script to not write password to disk. I need a fileless equivalent of this "< c:\temp\configvpn.txt"

I tried :

    @echo %user_id%
    @echo %pwd% 
) | %install_dir%\vpncli.exe connect myvpn.mydomain.TLD -s

Not success so far. The output is this loop:

  >> Please enter your username and password.

Username: [myUsername] Password:
  >> Login failed.

Username: [myUsername] Password:
  >> Login failed.

(repeats indefinitely)

Is there a way to do this?

  • It seems vpncli.exe supports giving the username and password as parameters. See docstore.mik.ua/univercd/cc/td/doc/product/vpn/client/3_6/… – LPChip Dec 11 '18 at 15:38
  • so: vpncli connect myvpn.mydomain.tld user MyUser pwd MyPass – LPChip Dec 11 '18 at 15:39
  • Actually no. This is old documentation of legacy VPN Client. I tried myself but current vpncli (referring anyconnect 4.6) throws an error using this syntax. Thanks anyway – Filipe Dec 11 '18 at 17:47
  • Question was asked and answered on StackOverFlow – Squashman Dec 12 '18 at 4:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.