2

I am using child_process to launch software from Windows clients connected on my server. The general cases are working like a charm but in one I have a "&" sign which fails the command to launch.

Is there a way to escape this kind of special char ?

Here is a example of my command:

var exec = require('child_process').exec, child;
child = exec('C:/Programs/program.exe /Callback:other&program.exe /Start');

There is one constraint: I cannot use /Callback:"other&program.exe" because program.exe is no to smart to escape the " signs

Akira
  • 160
  • 1
  • 12
  • Try pass `/Callback:other&program.exe /Start` as options (array) to exec. – Aikon Mogwai Aug 03 '16 at 18:35
  • as you can see in [documentation](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback), options is not used for command parameters but for exec specific options. – Akira Aug 03 '16 at 19:26
  • 1
    Yeah. Your answer is here - http://stackoverflow.com/questions/1327431/how-do-i-escape-ampersands-in-batch-files . Use `^` to mask ampersand `&`. – Aikon Mogwai Aug 03 '16 at 20:00

1 Answers1

3

As Aikon Mogwai said (thanks to him):

Use ^ to mask ampersand &.

This is working for child_process exec command.

Akira
  • 160
  • 1
  • 12