@@ -120,23 +120,19 @@ however, `.bat` and `.cmd` files are not executable on their own without a
120120terminal, and therefore cannot be launched using [ ` child_process.execFile() ` ] [ ] .
121121When running on Windows, ` .bat ` and ` .cmd ` files can be invoked by:
122122
123- * using [ ` child_process.spawn() ` ] [ ] with the ` shell ` option set, or
123+ * using [ ` child_process.spawn() ` ] [ ] with the ` shell ` option set (not recommended, see [ DEP0190 ] [ ] ) , or
124124* using [ ` child_process.exec() ` ] [ ] , or
125125* spawning ` cmd.exe ` and passing the ` .bat ` or ` .cmd ` file as an argument
126- (which is what the ` shell ` option and [ ` child_process.exec() ` ] [ ] do ).
126+ (which is what [ ` child_process.exec() ` ] [ ] does internally ).
127127
128128In any case, if the script filename contains spaces, it needs to be quoted.
129129
130130``` cjs
131131const { exec , spawn } = require (' node:child_process' );
132132
133- // 1. child_process.spawn() with the shell option set
134- const myBat = spawn (' my.bat' , { shell: true });
135-
136- // 2. child_process.exec()
137133exec (' my.bat' , (err , stdout , stderr ) => { /* ... */ });
138134
139- // 3. spawning cmd.exe and passing the .bat or .cmd file as an argument
135+ // Or, spawning cmd.exe directly:
140136const bat = spawn (' cmd.exe' , [' /c' , ' my.bat' ]);
141137
142138// If the script filename contains spaces, it needs to be quoted
@@ -146,13 +142,9 @@ exec('"my script.cmd" a b', (err, stdout, stderr) => { /* ... */ });
146142``` mjs
147143import { exec , spawn } from ' node:child_process' ;
148144
149- // 1. child_process.spawn() with the shell option set
150- const myBat = spawn (' my.bat' , { shell: true });
151-
152- // 2. child_process.exec()
153145exec (' my.bat' , (err , stdout , stderr ) => { /* ... */ });
154146
155- // 3. spawning cmd.exe and passing the .bat or .cmd file as an argument
147+ // Or, spawning cmd.exe directly:
156148const bat = spawn (' cmd.exe' , [' /c' , ' my.bat' ]);
157149
158150// If the script filename contains spaces, it needs to be quoted
@@ -2369,6 +2361,7 @@ Therefore, this feature requires opting in by setting the
23692361or [`child_process.fork()`][].
23702362
23712363[Advanced serialization]: #advanced-serialization
2364+ [DEP0190]: deprecations.md#DEP0190
23722365[Default Windows shell]: #default-windows-shell
23732366[HTML structured clone algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
23742367[Shell requirements]: #shell-requirements
0 commit comments