Escape Characters in Windows Command Line

Escape Characters in Windows’ CMD.EXE doesn’t entirely work for me. I wanted to embed or escape quote characters in a command line, to give to the binPath parameter of sc.exe to create a windows service. But this contribution from John McNelly in the comments did give the solution:

John McNelly •  Jun 4, 2009 @1:10 pm

You can also use ^ as a line continuation character for readability.
To escape an embedded ” use a backslash, useful with paths within “c:\Program Files” :

sc.exe create Foo ^
binPath= "\"C:\Program Files\foo.exe\" \"C:\Program Files\foo.ini\"" ^
displayName= "Hello, world"

Thanks John.

Leave a Reply

Your email address will not be published. Required fields are marked *