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.
Group: VPN-TESTGROUP
Username: [myUsername] Password:
>> Login failed.
Group: VPN-TESTGROUP
Username: [myUsername] Password:
>> Login failed.
(repeats indefinitely)
Is there a way to do this?