Skip to content

Instantly share code, notes, and snippets.

@JackieLin
Created April 10, 2014 09:09
Show Gist options
  • Save JackieLin/10359882 to your computer and use it in GitHub Desktop.
Save JackieLin/10359882 to your computer and use it in GitHub Desktop.
show Windows system letter using node.js
var exec = require('child_process').exec;
// show Windows letter, to compatible Windows xp
function showLetter(callback) {
var wmicResult;
var command = exec('wmic logicaldisk get caption', function(err, stdout, stderr) {
if(err || stderr) {
console.log("root path open failed" + err + stderr);
return;
}
wmicResult = stdout;
});
command.stdin.end(); // stop the input pipe, in order to run in windows xp
command.on('close', function(code) {
console.log("wmic close:: code:" + code);
var data = wmicResult.split('\n'), result = {};
callback(result);
});
}
/**
* output:
* Caption
* C:
* D:
* E:
* F:
* G:
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment