@guidepup/setup
Version:
Setup your environment for screen-reader automation.
29 lines (25 loc) • 923 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.restartExplorer = restartExplorer;
const errors_1 = require("../errors");
const runVbsScript_1 = require("./runVbsScript");
async function restartExplorer() {
const script = `
SET objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" & chr(92) & chr(92) & "." & chr(92) & "root" & chr(92) & "cimv2")
SET colProcesses = objWMIService.ExecQuery("Select * from Win32_Process where Name = 'explorer.exe'")
FOR EACH objProcess in colProcesses
objProcess.Terminate(1)
NEXT
SET objWMIService = Nothing
SET colProcesses = Nothing
SET WshShell = CreateObject("WScript.Shell")
WshShell.Run "explorer.exe"
SET WshShell = Nothing
`;
try {
await (0, runVbsScript_1.runVbsScript)(script);
}
catch (e) {
throw new Error(`${errors_1.ERR_WINDOWS_FAILED_TO_RESTART_EXPLORER}\n\n${e.message}`);
}
}