private async spawnChromeUnelevatedWithWindowsScriptHost()

in src/chromeDebugAdapter.ts [495:517]


    private async spawnChromeUnelevatedWithWindowsScriptHost(chromePath: string, chromeArgs: string[]): Promise<number> {
        const semaphoreFile = path.join(os.tmpdir(), 'launchedUnelevatedChromeProcess.id');
        if (fs.existsSync(semaphoreFile)) { // remove the previous semaphoreFile if it exists.
            fs.unlinkSync(semaphoreFile);
        }
        const chromeProc = fork(getChromeSpawnHelperPath(),
            [`${process.env.windir}\\System32\\cscript.exe`, path.join(__dirname, 'launchUnelevated.js'),
            semaphoreFile, chromePath, ...chromeArgs], {});

        chromeProc.unref();
        await new Promise<void>((resolve, reject) => {
            chromeProc.on('message', resolve);
        });

        const pidStr = await findNewlyLaunchedChromeProcess(semaphoreFile);

        if (pidStr) {
            logger.log(`Parsed output file and got Chrome PID ${pidStr}`);
            return parseInt(pidStr, 10);
        }

        return null;
    }