mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-30 09:03:20 -05:00
1 line
5.0 KiB
JavaScript
1 line
5.0 KiB
JavaScript
|
var promise=require("promise");function qfe(){var a=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.waitExit();var e=a.stdout.str.trim().split("\r\n");var d=e[0].split(",");var b,c;var h;var g=[];for(b=1;b<e.length;++b){var f={};h=e[b].split(",");for(c=0;c<d.length;++c){if(h[c]){f[d[c]]=h[c]}}g.push(f)}return(g)}function av(){var a=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.waitExit();var e=a.stdout.str.trim().split("\r\n");var d=e[0].split(",");var b,c;var j;var g=[];for(b=1;b<e.length;++b){var f={};var h={};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)}function defrag(a){var c=new promise(function(e,d){this._res=e;this._rej=d});var b="";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){var f=this.stdout.str.trim().split("\r\n");var g={volume:this.promise.options.volume};for(var e in f){var h=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)}function regQuery(b,d,c){try{return(require("win-registry").QueryKey(b,d,c))}catch(a){return(null)}}function pendingReboot(){var c=null;var b=null;var a=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)}function installedApps(){var b=require("promise");var c=new b(function(d,e){this._resolve=d;this._reject=e});var a=" var reg = require('win-registry'); var result = []; var val, tmp; var items = reg.QueryKey(reg.HKEY.LocalMachine, 'SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall'); for (var key in items.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[key], 'DisplayVersion'); if (val.version == '') { delete val.version; } } catch(e) { } try
|