How to open a new command line window and execute a bash command which runs in a separate independent process?
I tried
var child_process = require('child_process');
child_process.execSync("cmd.exe /K node my-new-script.js parm1 parm2);
but it opens no new window and I need an independent process (if possible). The background is I am experimenting with electron and wrote some node command line scripts. Unfortunately within electron environment spawning processes results often in weird behavior and console log output is more than ugly.
By the way I would need something equivalent to OS X and Linux.
var objShell = new ActiveXObject("Shell. Application"); objShell. ShellExecute("cmd.exe", "C: cd C:\\pr main.exe blablafile. txt auto", "C:\\WINDOWS\\system32", "open", "1");
Opening: WindowsGo to Start menu → Windows System → Command Prompt. Go to Start menu → All Programs → Accessories → Command Prompt. Go to the Start screen, hover your mouse in the lower-left corner of the screen, and click the down arrow that appears (on a touch screen, instead flick up from the bottom of the screen).
It is a computer environment the same as command prompt and an easy way to test simple Node. js/JavaScript code and allows to execute multiple javascript codes. we can simply run REPL on the command prompt using node command on the command prompt.
Press Windows+R to open “Run” box. Type “cmd” and then click “OK” to open a regular Command Prompt. Type “cmd” and then press Ctrl+Shift+Enter to open an administrator Command Prompt.
For Windows, you'll need to use the start
command:
start cmd.exe /K node my-new-script.js parm1 parm2
For OS X, you can use:
osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down'
For other *nix distros, you'll need to look those up as each one is slightly different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With