windows - Escaping everything in batch files -


i've got list of commands (generated nmake , obtained using event tracing) want run. obvious way put them in batch file. works fine simple commands, 1 of them turned out following:

c:\windows\system32\cmd.exe /c %i in (..\..\bin\*) @for %j in ("%~ni.exe: $(srcdir)/bin/%~ni" "  $(echo) generating $(@)" "  $(q) copy /y /b $(stubprogram) $(@) > nul" "    $(q) echo.>>$(@)" " $(q) echo.>>$(@)" " $(q) copy /b $(@)+$(srcdir:/=\)\bin\%~ni $(@) > nul" "" ) @echo.%~j>>scriptbin.mk 

which cmd barfed on:

the following usage of path operator in batch-parameter substitution invalid: %~ni.exe: $(srcdir)/bin/%~ni" "        $(echo) generating $(@)" "      $(q) copy /y /b $(stubprogram) $(@) > nul" "    $(q) echo.>>$(@)" "     $(q) echo.>>$(@)" "     $(q) copy /b $(@)+$(srcdir:/=\)\bin\%~ni $(@) > nul" "" ) @echo.%~j>>scriptbin.mk 

which suppose shouldn't surprising act of reading commands batch file performs various substitutions, interpretations of special characters et cetera.

i try modify stuff in batch file escaping things, require program escaping know there know how cmd parses things , needs escaped; see myself still trying fix bugs in time next year.

i write own program run batch file without doing substitutions or interpretations, wouldn't having batch files can run as-is.

is there way 'escape everything' or 'turn off substitutions rest of file' or that?

it seems solve problem if run batch file with:

cmd <foo.bat 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -