Command Line Arguments

Morning Guys

Wondered if you could help. I’m trying to send the following command line arguments to the Cisco Anywhere connect VPN command line without much luck.

I need to pass:

–s < C:\Temp\Connect.txt

To

'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe'

So the line should like:

'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' –s < C:\Temp\Connect.txt

The issue seems to be the < I've tried multiple ways but with no joy, can anyone help me please?

Many thanks

Barry

Try this:

& 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' --% –s < C:\Temp\Connect.txt

Hi Richard

Thanks for your reply. I did try that before and it fails with

The ‘<’ operator is reserved for future use.

Thanks

Barry

That is strange. PowerShell should ignore what is coming after the --% and pass it to the referenced executable. You’re using a double dash?

Yep def, just doubled checked.

Thanks

That symbol isn’t actually passed to the executable. Whatever documentation you’re reading probably assumes that you’re running it from cmd.exe, where the < operator is input redirection. Without knowing how their app works, the simplest thing to do in PowerShell is probably just to wrap the call in a call to cmd.exe:

cmd.exe /c '"C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe" –s < C:\Temp\Connect.txt'

Hi Dave

That works perfectly!

Many thanks for your help

Barry

Dave, do you know why --% doesn’t work in this situation? My impression always was that PowerShell would pass whatever you typed to the executable?

I thought so as well, but maybe the pipe and/or redirection operators still take precedence. Haven’t played with that much.

Look like a little bug then in the --% escape character. I wonder if you could escape it. But putting it in single quotes is much simpler, as you proposed. :slight_smile:

@Barry: would you be so nice to try this, to satisfy my curiosity? :slight_smile: :

& 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' --% –s `< C:\Temp\Connect.txt

Hi Richard

Tried the suggested change and back to the first error:

The ‘<’ operator is reserved for future use.

Thanks

Barry

Thanks Barry! Seems indeed that redirection characters cannot be parsed with the --% escape character as a string. Seems a bug to me.