user837208
user837208

Reputation: 2577

unable to escape space in command shell of Windows

If I execute

cmd /c "%programfiles%\mycode\md5sums.exe" %temp%

it works just fine. But when I execute

cmd /c "%programfiles%\mycode\md5sums.exe" %programfiles%

I get below error-

Error: Unable to read file/directory C:\Program

which means that md5sums.exe is trying to open C:\Program as opposed to full path given by %programfiles%

I've to use cmd /c as I've to run this command remotely.

How do I make it work? I've tried using `"%programfiles%" but in this case even md5sums.exe is not getting executed.

Eventually I would like to use switch "/b" provided by md5sums.exe but at this point of time I am stuck at even making md5sums run on %programfiles%

Upvotes: 1

Views: 9727

Answers (2)

mausi
mausi

Reputation: 11

you need a double double quote at start and end e.g.:

cmd /c ""%programfiles%\mycode\md5sums.exe" "%programfiles%""

Upvotes: 1

Marc B
Marc B

Reputation: 360632

Try:

cmd /c "%programfiles%\mycode\md5sums.exe" "%programfiles%"
                                           ^--------------^--quotes added

Otherwise, you end up with something like:

cmd /c "C:\Program Files\mycode\md5sums.exe" C:\Program Files

and end up passing two arguments to md5sums, not a single path.

Upvotes: 4

Related Questions