1const { exec, spawn } = require("child_process");
2const psList = require("ps-list");
3
4const EDITOR_PATH = "Editor_x64.exe";
5
6async function findProcess(name) {
7 const processes = await psList();
8 return processes.find(p => p.name.toLowerCase() === name.toLowerCase());
9}
10
11async function suspendProcess(pid) {
12 exec(`powershell -Command "Stop-Process -Id ${pid} -Force"`, (error) => {
13 if (error) console.log("Error suspending process:", error);
14 else console.log("Process suspended.");
15 });
16}
17
18async function runEditor() {
19 spawn(EDITOR_PATH, { detached: true });
20 console.log("Second instance launched.");
21}
22
23(async () => {
24 const processInfo = await findProcess("Editor_x64.exe");
25 if (processInfo) {
26 console.log(`Editor found with PID ${processInfo.pid}. Suspending.`);
27 await suspendProcess(processInfo.pid);
28 }
29 runEditor();
30})();
31