Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following appcmd to add an exception to IIS7's ISAPI and CGI restrictions. The exception I am adding should look like:

c:\perl\bin\perl.exe "%s" %s

Here is the command line:

appcmd set config -section:isapiCgiRestriction "-+[path='c:\perl\bin\perl.exe \"%s\" %s', allowed='true', description='Perl CGI']"

If execute this from the command line it does this correctly, however if I execute this inside a .cmd batch file the path gets mangled and ends up looking like:

c:\perl\bin\perl.exe "s

The trouble seems arise because I have to escape the quotation marks around the first %s perl.exe parameter. But why this should behave differently in a batch file is a bit of a puzzle.

Can anyone explain why this is happening?

share|improve this question
    
Sorry to spam this over SO and SF....seems to fall into both sites. –  Kev Sep 8 '10 at 10:38
add comment

1 Answer

up vote 2 down vote accepted

Windows batch variables should be prefixed with an %, making these %%s

share|improve this answer
    
That fixes the batch file execution but breaks if executed from the command line. If run from command line I get c:\perl\bin\perl.exe "%%s" %%s which breaks the ISAPI restriction because IIS expects c:\perl\bin\perl.exe "%s" %s. But because I'm solving this for task automation I can live with that. I'm guessing this has something to do with differences in the way that the command line processor handles variable expansion. Thanks for the speedy answer though. –  Kev Sep 8 '10 at 11:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.