MCPcopy
hub / github.com/koodo-reader/koodo-reader / runPowerShellScript

Function runPowerShellScript

main.js:92–122  ·  view source on GitHub ↗
(script, timeout = 30000)

Source from the content-addressed store, hash-verified

90};
91
92const 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
124const getWindowHandleValue = (win) => {
125 if (!win || typeof win.getNativeWindowHandle !== "function") {

Callers 2

getBiometricCapabilityFunction · 0.85
promptBiometricAuthFunction · 0.85

Calls 2

extractClixmlErrorsFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected