(script, timeout = 30000)
| 90 | }; |
| 91 | |
| 92 | const runPowerShellScript = (script, timeout = 30000) => { |
| 93 | return new Promise((resolve, reject) => { |
| 94 | const encodedCommand = Buffer.from(script, "utf16le").toString("base64"); |
| 95 | execFile( |
| 96 | "powershell.exe", |
| 97 | [ |
| 98 | "-NoProfile", |
| 99 | "-NonInteractive", |
| 100 | "-Sta", |
| 101 | "-ExecutionPolicy", |
| 102 | "Bypass", |
| 103 | "-EncodedCommand", |
| 104 | encodedCommand, |
| 105 | ], |
| 106 | { |
| 107 | windowsHide: true, |
| 108 | timeout, |
| 109 | maxBuffer: 1024 * 1024, |
| 110 | }, |
| 111 | (error, stdout, stderr) => { |
| 112 | if (error) { |
| 113 | const rawMessage = (stderr || stdout || error.message || "").trim(); |
| 114 | const cleanMessage = extractClixmlErrors(rawMessage) || rawMessage; |
| 115 | reject(new Error(cleanMessage)); |
| 116 | return; |
| 117 | } |
| 118 | resolve((stdout || "").trim()); |
| 119 | } |
| 120 | ); |
| 121 | }); |
| 122 | }; |
| 123 | |
| 124 | const getWindowHandleValue = (win) => { |
| 125 | if (!win || typeof win.getNativeWindowHandle !== "function") { |
no test coverage detected