nodejs 运行CMD命令
Posted zhen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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\'); }
参考:
Node-cmd npm
child_process
参考:
以上是关于nodejs 运行CMD命令的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Nodejs 和 spawn 在 Windows 10 上以管理员身份运行一些 CMD 命令?
Android 逆向Android 逆向通用工具开发 ( Android 平台运行的 cmd 程序类型 | Android 平台运行的 cmd 程序编译选项 | 编译 cmd 可执行程序 )(代码片段