If you think it's bad, did you know that cmd.exe (Windows NT) and command.com (Windows 9X) have different rules for how you need to quote/escape filenames when passing them a string to execute? I guess that system()
hides that difference.
Code: Select all
shell "printcmdline /FI ""IMAGENAME eq notepad.exe"""
and it worked fine: COMMAND(2) is "IMAGENAME eq notepad.exe" (no quotes).
On Unix, the shell splits up the commandline into arguments and passes them to the invoked program, but on Windows each program is responsible for splitting the arguments itself! The C runtime (msvcrt) implements splitting of arguments (the parse_cmdline()
internal function) which it passes to main(), but not all Windows programs use msvcrt, so handling of escaping could technically be inconsistent (I don't know if exceptions exist in practice)