1

I want to run iisexpress inside cmd and start it from powershell. I have a strange issue with escaping double quotes. My original powershell command is

Start-Process 'cmd' -ArgumentList '/k "C:/Program Files/IIS Express/iisexpress.exe" /config:"d:\Repo\app\applicationhost.config" /apppool:"Clr4IntegratedAppPool"' 

It fails with

'C:/Program' is not recognized as an internal or external command,
operable program or batch file.

There is clearly some issues with double quotes, however when I try to run iis without arguments it actually starts it

Start-Process 'cmd' -ArgumentList '/k "C:/Program Files/IIS Express/iisexpress.exe"'

I noticed it feels fine until I type a double quote after iisexpress.exe". For instance, just Start-Process 'cmd' -ArgumentList '/k "C:/Program Files/IIS Express/iisexpress.exe" /config:" is failing with 'C:/Program' is not recognized, but Start-Process 'cmd' -ArgumentList '/k "C:/Program Files/IIS Express/iisexpress.exe" /config: also fails, but it tells that I should provide a value for the argument.

All in all, how to avoid the issue with arguments for iisexpress?

1 Answer 1

2

You've run into a cmd.exe parsing "quirk", which you can avoid by enclosing everything that follows /k (or /c) in "..." (incredibly, this does then not require escaping the then embedded " chars):

Start-Process 'cmd' -ArgumentList '/k " "C:/Program Files/IIS Express/iisexpress.exe" /config:"d:\Repo\app\applicationhost.config" /apppool:"Clr4IntegratedAppPool" "'

The problem occurs when both a double-quoted executable path and double-quoted arguments are present and there is no overall "..." enclosure. (There are situational exceptions, but overall "..." enclosure is the safe choice.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.