node child_process文档
child_process.exec(command[,options][,callback])
-
command
<string> The command to run,with space-separated arguments. -
options
<Object>-
cwd
<string> Current working directory of the child process. Default:null
. -
env
<Object> Environment key-value pairs. Default:null
. -
encoding
<string> Default:'utf8'
-
shell
<string> Shell to execute the command with. See Shell Requirements and Default Windows Shell. Default:'/bin/sh'
on UNIX,process.env.ComSpec
on Windows. -
timeout
<number> Default:0
-
maxBuffer
<number> Largest amount of data in bytes allowed on stdout or stderr. If exceeded,the child process is terminated. See caveat atmaxBuffer
and Unicode. Default:200 * 1024
. -
killSignal
<string> | <integer> Default:'SIGTERM'
-
uid
<number> Sets the user identity of the process (seesetuid(2)
). -
gid
<number> Sets the group identity of the process (seesetgid(2)
). -
windowsHide
<boolean> Hide the subprocess console window that would normally be created on Windows systems. Default:false
.
-
-
callback
<Function> called with the output when process terminates.
init(list){//得到硬盘分区的数组 let ths = this; let lists = ths.arrayTrim(list); return lists; } arrayTrim(arr){数组中各元素的空格去除 arr.shift(); arr.forEach(function(item,index){ arr[index] = item.trim(); }); arr; } logicaldisk(){获取自盘分区的字符串 var ths = ; spawn.exec('wmic logicaldisk get caption',{ windowsHide: true },(err,stdout,stderr) { if(err || stderr) { console.log("root path open failed" + err + stderr); ; } let disks = stdout.trim().split('\n'); ths.init(disks); }) }
原文地址:https://www.cnblogs.com/guojikun
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。