varpromise=require("promise");functionqfe(){vara=require("child_process").execFile(process.env.windir+"\\System32\\wbem\\wmic.exe",["wmic","qfe","list","full","/FORMAT:CSV"]);a.stdout.str="";a.stdout.on("data",function(i){this.str+=i.toString()});a.stderr.str="";a.stderr.on("data",function(i){this.str+=i.toString()});a.waitExit();vare=a.stdout.str.trim().split("\r\n");vard=e[0].split(",");varb,c;varh;varg=[];for(b=1;b<e.length;++b){varf={};h=e[b].split(",");for(c=0;c<d.length;++c){if(h[c]){f[d[c]]=h[c]}}g.push(f)}return(g)}functionav(){vara=require("child_process").execFile(process.env.windir+"\\System32\\wbem\\wmic.exe",["wmic","/Namespace:\\\\root\\SecurityCenter2","Path","AntiVirusProduct","get","/FORMAT:CSV"]);a.stdout.str="";a.stdout.on("data",function(i){this.str+=i.toString()});a.stderr.str="";a.stderr.on("data",function(i){this.str+=i.toString()});a.waitExit();vare=a.stdout.str.trim().split("\r\n");vard=e[0].split(",");varb,c;varj;varg=[];for(b=1;b<e.length;++b){varf={};varh={};j=e[b].split(",");for(c=0;c<d.length;++c){if(j[c]!=undefined){f[d[c].trim()]=j[c]}}h.product=f.displayName;h.updated=(parseInt(f.productState)&16)==0;h.enabled=(parseInt(f.productState)&4096)==4096;g.push(h)}return(g)}functiondefrag(a){varc=newpromise(function(e,d){this._res=e;this._rej=d});varb="";switch(require("os").arch()){case"x64":if(require("_GenericMarshal").PointerSize==4){c._rej("Cannot defrag volume on 64 bit Windows from 32 bit application");return(c)}else{b=process.env.windir+"\\System32\\defrag.exe"}break;case"ia32":b=process.env.windir+"\\System32\\defrag.exe";break;default:c._rej(require("os").arch()+" not supported");return(c);break}c.child=require("child_process").execFile(process.env.windir+"\\System32\\defrag.exe",["defrag",a.volume+" /A"]);c.child.promise=c;c.child.promise.options=a;c.child.stdout.str="";c.child.stdout.on("data",function(d){this.str+=d.toString()});c.child.stderr.str="";c.child.stderr.on("data",function(d){this.str+=d.toString()});c.child.on("exit",function(d){varf=this.stdout.str.trim().split("\r\n");varg={volume:this.promise.options.volume};for(vareinf){varh=f[e].split("=");if(h.length==2){switch(h[0].trim().toLowerCase()){case"volume size":g.size=h[1];break;case"free space":g.free=h[1];break;case"total fragmented space":g.fragmented=h[1];break;case"largest free space size":g.largestFragment=h[1];break}}}this.promise._res(g)});return(c)}functionregQuery(b,d,c){try{return(require("win-registry").QueryKey(b,d,c))}catch(a){return(null)}}functionpendingReboot(){varc=null;varb=null;vara=require("win-registry").HKEY;if(regQuery(a.LocalMachine,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing","RebootPending")!=null){b="Component Based Servicing"}else{if(regQuery(a.LocalMachine,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate","RebootRequired")){b="Windows Update"}else{if((c=regQuery(a.LocalMachine,"SYSTEM\\CurrentControlSet\\Control\\Session Manager","PendingFileRenameOperations"))!=null&&c!=0&&c!=""){b="File Rename"}else{if(regQuery(a.LocalMachine,"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName","ComputerName")!=regQuery(a.LocalMachine,"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName","ComputerName")){b="System Rename"}}}}return(b)}functioninstalledApps(){varb=require("promise");varc=newb(function(d,e){this._resolve=d;this._reject=e});vara="varreg=require('win-registry');varresult=[];varval,tmp;varitems=reg.QueryKey(reg.HKEY.LocalMachine,'SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall');for(varkeyinitems.subkeys){val={};try{val.name=reg.QueryKey(reg.HKEY.LocalMachine,'SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\'+items.subkeys[key],'DisplayName');}catch(e){continue;}try{val.version=reg.QueryKey(reg.HKEY.LocalMachine,'SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\'+items.subkeys[