// Reference Manual: https://wutils.com/wmi/root/cimv2/default.html try { FSO = new ActiveXObject("Scripting.FileSystemObject"); FSO.CreateFolder('C:\\TEMP'); } catch(e) {} try { WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run('CMD /C WMIC COMPUTERSYSTEM GET TotalPhysicalMemory > C:\\TEMP\\TOTALMEM.TMP', 9, 1); } catch (e) {} try { FILE = FSO.OpenTextFile('C:\\TEMP\\TOTALMEM.TMP', 1, 0, 0); DATA = FILE.ReadAll(); FILE.Close(); } catch(e) {} PHYSTOTAL = tr(DATA, '0123456789') / 1024; try { WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2"); M = WMI.ExecQuery("select * from Win32_PerfFormattedData_PerfOS_System"); e = new Enumerator(M); UPTIME = e.item().SystemUpTime; PROCESSES = e.item().Processes; THREADS = e.item().Threads; M = WMI.ExecQuery("select * from Win32_PhysicalMemory"); e = new Enumerator(M); RAMINSTALLED = e.item().Capacity / 1024; M = WMI.ExecQuery("select * from Win32_PerfFormattedData_PerfOS_Memory"); e = new Enumerator(M); PHYSFREE = e.item().AvailableKBytes; SWAPTOTAL = e.item().CommitLimit / 1024; SWAPUSED = e.item().CommittedBytes / 1024; } catch (e) {} PHYSUSED = (PHYSTOTAL - PHYSFREE); SWAPFREE = SWAPTOTAL - SWAPUSED; VMTOTAL = PHYSTOTAL + SWAPTOTAL; VMUSED = PHYSUSED + SWAPUSED; VMFREE = VMTOTAL - VMUSED; VMPERCENT = Math.round((VMUSED / (VMTOTAL + 0.00001)) * 100); SWAPPERCENT = Math.round((SWAPUSED / (SWAPTOTAL + 0.00001)) * 100); PHYSPERCENT = Math.round((PHYSUSED / (PHYSTOTAL + 0.00001)) * 100); INDENT = " "; WScript.Echo("JAVASCRIPT MEMORY REPORT\n\n" + INDENT + "UPTIME: " + UPTIME + " seconds PROCESSES: " + PROCESSES + " THREADS: " + THREADS + "\n\n" + INDENT + Math.round(RAMINSTALLED / 1024) + " MB ... Total Physical Memory Installed\n" + INDENT + Math.round(PHYSTOTAL / 1024) + " MB ... Total Physical Memory Accessible by Windows\n" + INDENT + Math.round(PHYSFREE / 1024) + " MB ... Free Physical Memory\n" + INDENT + Math.round(PHYSUSED / 1024) + " MB ... Used Physical Memory " + PHYSPERCENT + "% used\n\n" + INDENT + Math.round(SWAPTOTAL / 1024) + " MB ... Total Swap Space\n" + INDENT + Math.round(SWAPUSED / 1024) + " MB ... Used Swap Space\n" + INDENT + Math.round(SWAPFREE / 1024) + " MB ... Free Swap Space " + SWAPPERCENT + "% used\n\n" + INDENT + Math.round(VMTOTAL / 1024) + " MB ... Total Virtual Memory\n" + INDENT + Math.round(VMUSED / 1024) + " MB ... Used Virtual Memory\n" + INDENT + Math.round(VMFREE / 1024) + " MB ... Free Virtual Memory " + VMPERCENT + "% used\n\n" + "Written by Zsolt Nagy-Perge (zsnp@juno.com)\nin August 2022, Pensacola, Fla."); ////////////////////////////////////////////////// // v2021.3.15 // This function removes all characters from STR // that do not appear anywhere in CHARSET, forcing // string to be only made up of the given characters. // Example: tr("cabbage cake", " abc") --> "cabba ca" // Usage: STRING = tr(STRING, STRING) // function tr(STR, CHARSET) { STR += ""; STR = STR.split(""); for (var i = 0; i < STR.length; i++) if (CHARSET.indexOf(STR[i]) < 0) STR[i] = ""; return STR.join(""); } //////////////////////////////////////////////////