From ec55d7e9134dae86494873fb57e30d87a69897bd Mon Sep 17 00:00:00 2001 From: jcnmsg <19619630+jcnmsg@users.noreply.github.com> Date: Sun, 20 Feb 2022 15:18:13 +0000 Subject: [PATCH] Discontinue WMIC, use powershell --- lib/disk.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/disk.js b/lib/disk.js index fc5d52e..2c26557 100644 --- a/lib/disk.js +++ b/lib/disk.js @@ -40,26 +40,30 @@ switch(process.env.platform) { case 'win': module.exports = function(statEmitter, options) { - let wmic = 'wmic LOGICALDISK GET Name, Size, FreeSpace /value | findstr "FreeSpace Name Size"'; - exec(wmic, function(err, output, code) { + let powershell = 'powershell Get-CimInstance -ClassName Win32_LogicalDisk'; + exec(powershell, function(err, output, code) { if(err) return; let segments = output.split('\n'); - for(let i=0; i options.threshold) { - statEmitter.emit('disk', { filesystem: filesystem, usedpct: usedpct, total: total, free: free }); - } + for(let i=3; i options.threshold) { + statEmitter.emit('disk', { filesystem: filesystem, usedpct: usedpct, total: total, free: free }); } }