-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysinfo.js
More file actions
36 lines (33 loc) · 1.12 KB
/
sysinfo.js
File metadata and controls
36 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { ipcMain } = require("electron");
const { execFile } = require("child_process");
const path = require("path");
function getSysInfo() {
const script = path.join(__dirname, "scripts", "get-sysinfo.ps1");
return new Promise((resolve) => {
execFile("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", script],
{ maxBuffer: 5 * 1024 * 1024, windowsHide: true },
(err, stdout) => {
if (err) return resolve(null);
try {
resolve(JSON.parse(stdout.trim()));
} catch { resolve(null); }
}
);
});
}
function getLiveStats() {
const script = path.join(__dirname, "scripts", "get-live-stats.ps1");
return new Promise((resolve) => {
execFile("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", script],
{ maxBuffer: 1024 * 1024, windowsHide: true },
(err, stdout) => {
if (err) return resolve(null);
try {
resolve(JSON.parse(stdout.trim()));
} catch { resolve(null); }
}
);
});
}
ipcMain.handle("get-sysinfo", () => getSysInfo());
ipcMain.handle("get-live-stats", () => getLiveStats());