Is there a way to retrieve the drive name of all logical drives on a computer ?
I've looked at the fs api, but from there I can only enumerate the files and directories of a given directory.
How about using the DiskPart command? Does running diskpart list in the command line give you the output you need? If so you can execute this in node using child_process.exec
var exec = require('child_process).exec
var cmd = 'diskpart list'
exec(cmd, function(err, stdout, stderr) {
if (err) {
console.log('error running diskpart list command')
console.log(err)
return
}
console.log('stdout data')
console.log(stdout)
console.log('stderr data')
console.log(stderr)
})
I'm not sure what you mean by "drive name". If you mean drives in the form of \\.\PhysicalDriveN, I faced the same problem and implemented this module that works in all major operating systems:
https://github.com/resin-io/drivelist
For Windows, you get information such as:
[
{
device: '\\\\.\\PHYSICALDRIVE0',
description: 'WDC WD10JPVX-75JC3T0',
size: '1000 GB'
},
{
device: '\\\\.\\PHYSICALDRIVE1',
description: 'Generic STORAGE DEVICE USB Device',
size: '15 GB'
}
]