Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

execute command js

    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');
    }
Comment

javascript run command

const { execSync } = require('child_process');

const output = execSync('ls', { encoding: 'utf-8' });

console.log('The output is:');
console.log(output);
Comment

how to run commands in the command prompt using javascript

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
Comment

execute command js

<!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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: difference between var and let 
Javascript :: .join in javascript 
Javascript :: jquery each response 
Javascript :: Repeat a String Repeat a String 
Javascript :: javascript define global variable 
Javascript :: js is boolean 
Javascript :: javascript getting input from console 
Javascript :: javascript how to sort alphabetically 
Javascript :: set in javascript 
Javascript :: vue fix eslint error 
Javascript :: get current time jquery 
Javascript :: fonction fleche javascript 
Javascript :: How to fetch API data using POST and GET in PHP 
Javascript :: remove repeated characters from a string in javascript 
Javascript :: csv to json python 
Javascript :: background image in react from variable 
Javascript :: javascript today date in epoch 
Javascript :: remove specific element from array javascript 
Javascript :: how to clear state in react hooks 
Javascript :: Disable click for specific elements javascript 
Javascript :: ERROR Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager. 
Javascript :: react prevent component from update once mounted 
Javascript :: update data firestore 
Javascript :: convert a string to object javascript 
Javascript :: do while javascript 
Javascript :: javascript extend array 
Javascript :: javascript join array 
Javascript :: disable javascript chrome 
Javascript :: increased the value of a counter when a button is clicked in js 
Javascript :: javascript object to array 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =