nodejs 運行CMD命令


Node-cmd

安裝:

npm install node-cmd

npm install node-cmd –save // 安裝到工程目錄

兩種運行命令行方式:

 

method arguments functionality
run command runs a command asynchronously
get command,callback runs a command asynchronously, when the command is complete all of the stdout will be passed to the callback

API使用:

var nodeCmd = require('node-cmd');

function runCmdTest() {

    nodeCmd.get(

        'ipconfig',

        function(err, data, stderr){

            console.log(data);

        }

    );

 

    nodeCmd.run('ipconfig');

}

  

參考:

     RIAEvangelist/node-cmd  

     Node-cmd npm

     使用Nodejs在Windows上調用CMD命令

 

child_process

 

參考:

     nodejs調用腳本(python/shell)和系統命令

     Nodejs之如何調用 cmd 命令


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM