Ben Fortune Ben Fortune - 3 months ago 43
Node.js Question

Spawn child process escaping the quotes

I'm trying to add arguments which require the string to be quoted, but

spawn
is escaping them.

Code is as follows:

var printProc = spawn('RawPrintServer.exe', ['STANDALONE', '"RawPrinter"'], {
detached: true,
stdio: ['ignore', out, err]
});


When I check task manager, I can see that it has spawned it as

RawPrintServer.exe STANDALONE "\"RawPrinter\""


Whereas I need

RawPrintServer.exe STANDALONE "RawPrinter"

Answer

windowsVerbatimArguments

var printProc = spawn('RawPrintServer.exe', ['STANDALONE', '"RawPrinter"'], {
  detached: true,
  stdio: ['ignore', out, err],
  windowsVerbatimArguments: true
});

Found it mentioned on a bug (Quotes are not handled correctly when child_process.spawn() parses args) but I don't think it's documented.

Comments