var child_process = require('child_process'); child_process.exec('fsutil dirty query %systemdrive%', function(err, stdout){ if(err){ console.log('error', err); //Not OK return; } //OK, privileged });
要偵測是否是 UAC Privilege escalation,直接檢查是否Administrator並不可行,而是透過執行特定command來確認目前的執行是否是elevated privilege
這種作法在nodejs中不必在整合C API
參考: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights