How do you avoid cmd /c giving a broken error message when a file doesn't exist?
Posted: 21 Aug 2022 19:22
This, in CMD just running an executable, works
Here, cmd /c gives a broken error message when a file doesn't exist ..
I understand that looking at cmd /?, that cmd /c and cmd /k , have some strange rules..
I thought maybe CMD /C with /S might be worth a try, maybe it'd make it behave sanely, i.e. preserving spaces, but it didn't. Maybe /S is less sane 'cos maybe /S is what they call "old behaviour".. Though both with and without /S seems strange to me and different to regular CMD parsing(i.e. without /C or /K).
C:\blah>CMD /C "C:\Program Files\Windows NT\Accessories\zordpad.exe"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\blah>CMD /S /C "C:\Program Files\Windows NT\Accessories\zordpad.exe"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\blah>
[/code]
I notice this works
Is that what you're meant to do?
Why are all the rules different when you use CMD /C or /K, and in this case regardless of whether /S is used or not..
Code: Select all
C:\blah>"C:\Program Files\Windows NT\Accessories\zordpad.exe"
'"C:\Program Files\Windows NT\Accessories\zordpad.exe"' is not recognized as an internal or external command,
operable program or batch file.
I understand that looking at cmd /?, that cmd /c and cmd /k , have some strange rules..
I thought maybe CMD /C with /S might be worth a try, maybe it'd make it behave sanely, i.e. preserving spaces, but it didn't. Maybe /S is less sane 'cos maybe /S is what they call "old behaviour".. Though both with and without /S seems strange to me and different to regular CMD parsing(i.e. without /C or /K).
C:\blah>CMD /C "C:\Program Files\Windows NT\Accessories\zordpad.exe"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\blah>CMD /S /C "C:\Program Files\Windows NT\Accessories\zordpad.exe"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\blah>
[/code]
I notice this works
Code: Select all
C:\blah>CMD /C "C:\Program^ Files\Windows^ NT\Accessories\zordpad.exe"
'C:\Program Files\Windows NT\Accessories\zordpad.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\blah>CMD /S /C "C:\Program^ Files\Windows^ NT\Accessories\zordpad.exe"
'C:\Program Files\Windows NT\Accessories\zordpad.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\blah>
Why are all the rules different when you use CMD /C or /K, and in this case regardless of whether /S is used or not..