Author Posts

May 16, 2016 at 10:47 pm

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

May 17, 2016 at 2:05 am

Try this:

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

May 17, 2016 at 2:24 am

Hi Richard

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

The '<' operator is reserved for future use. Thanks Barry

May 17, 2016 at 2:27 am

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

May 17, 2016 at 2:31 am

Yep def, just doubled checked.

Thanks

May 17, 2016 at 4:05 am

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'

May 17, 2016 at 4:22 am

Hi Dave

That works perfectly!

Many thanks for your help

Barry

May 17, 2016 at 4:24 am

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?

May 17, 2016 at 4:26 am

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

May 17, 2016 at 4:30 am

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. 🙂

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

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

May 17, 2016 at 4:36 am

Hi Richard

Tried the suggested change and back to the first error:

The '<' operator is reserved for future use. Thanks Barry

May 17, 2016 at 4:38 am

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