try {
exec(CMD, (error, stdout, stderr) => {
if (error) {
console.log(error);
}
if (stdout) {
console.log(`out of the command : ${stdout}`);
}
if (stderr) {
console.log(`error with cmd : ${stderr}`);
return;
}
});
} catch {
console.log('error with cmd: cmd dosent launch');
}
const { execSync } = require('child_process');
const output = execSync('ls', { encoding: 'utf-8' });
console.log('The output is:');
console.log(output);
var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("cmd.exe", "C: cd C:pr main.exe blablafile.txt auto", "C:WINDOWSsystem32", "open", "1");
//NOTE: ONLY WORKS ON WINDOWS AS I KNOW OF
<!DOCTYPE html>
<html>
<body onkeydown="myFunction(event)">
<h1>The Document Object</h1>
<h2>The execCommand() Method</h2>
<p>The executeCommand() method executes a specified command on selected text.</p>
<p>Select some text in this page, and press SHIFT to make the selected text toggle between bold and normal.</p>
<script>
document.designMode = "on";
function myFunction(event) {
if (event.keyCode == 16) {
// Execute command if user presses the SHIFT button:
document.execCommand("bold");
}
}
</script>
</body>
</html>