@@ -3308,10 +3308,18 @@ async function execSdkManager(sdkManagerPath, javaPath, args) {
33083308 }
33093309 try {
33103310 exitCode = await new Promise((resolve, reject) => {
3311- const child = (0, child_process_1.spawn)(sdkManagerPath, args, {
3311+ let cmd = sdkManagerPath;
3312+ let cmdArgs = args;
3313+ if (process.platform === 'win32') {
3314+ if (!(0, utilities_1.isProcessElevated)()) {
3315+ throw new Error('Android SDK installation requires elevated (administrator) privileges. Please rerun as Administrator.');
3316+ }
3317+ cmd = 'cmd.exe';
3318+ cmdArgs = ['/c', sdkManagerPath, ...args];
3319+ }
3320+ const child = (0, child_process_1.spawn)(cmd, cmdArgs, {
33123321 stdio: ['pipe', 'pipe', 'pipe'],
33133322 env: {
3314- ...process.env,
33153323 JAVA_HOME: process.platform === 'win32' ? `"${javaPath}"` : javaPath
33163324 }
33173325 });
@@ -3331,7 +3339,7 @@ async function execSdkManager(sdkManagerPath, javaPath, args) {
33313339 function handleDataStream(data) {
33323340 const chunk = data.toString();
33333341 output += chunk;
3334- process.stderr .write(chunk);
3342+ process.stdout .write(chunk);
33353343 }
33363344 const acceptBuffer = Buffer.from(Array(10).fill('y').join(os_1.default.EOL), 'utf8');
33373345 child.stdin.write(acceptBuffer);
@@ -5942,6 +5950,7 @@ exports.WaitForFileToBeUnlocked = WaitForFileToBeUnlocked;
59425950exports.TestFileAccess = TestFileAccess;
59435951exports.KillProcess = KillProcess;
59445952exports.KillChildProcesses = KillChildProcesses;
5953+ exports.isProcessElevated = isProcessElevated;
59455954const os = __importStar(__nccwpck_require__(2037));
59465955const fs = __importStar(__nccwpck_require__(7147));
59475956const path = __importStar(__nccwpck_require__(1017));
@@ -6456,6 +6465,20 @@ async function KillChildProcesses(procInfo) {
64566465 logger.error(`Failed to kill child processes of pid ${procInfo.pid}:\n${JSON.stringify(error)}`);
64576466 }
64586467}
6468+ /**
6469+ * Checks if the current process is running with elevated (administrator) privileges.
6470+ * @returns True if the process is elevated, false otherwise.
6471+ */
6472+ function isProcessElevated() {
6473+ if (process.platform !== 'win32') {
6474+ return true;
6475+ } // We can sudo easily on non-windows platforms
6476+ const probe = (0, child_process_1.spawnSync)('powershell.exe', [
6477+ '-NoLogo', '-NoProfile', '-Command',
6478+ "[Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent().IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)"
6479+ ], { encoding: 'utf8' });
6480+ return probe.status === 0 && probe.stdout.trim().toLowerCase() === 'true';
6481+ }
64596482//# sourceMappingURL=utilities.js.map
64606483
64616484/***/ }),
0 commit comments