@@ -5,6 +5,7 @@ import { spawn } from 'child_process';
55import { Logger } from './logging' ;
66import { UnityEditor } from './unity-editor' ;
77import {
8+ isProcessElevated ,
89 ReadFileContents ,
910 ResolveGlobToPath
1011} from './utilities' ;
@@ -124,10 +125,21 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st
124125
125126 try {
126127 exitCode = await new Promise < number > ( ( resolve , reject ) => {
127- const child = spawn ( sdkManagerPath , args , {
128+ let cmd = sdkManagerPath ;
129+ let cmdArgs = args ;
130+
131+ if ( process . platform === 'win32' ) {
132+ if ( ! isProcessElevated ( ) ) {
133+ throw new Error ( 'Android SDK installation requires elevated (administrator) privileges. Please rerun as Administrator.' ) ;
134+ }
135+
136+ cmd = 'cmd.exe' ;
137+ cmdArgs = [ '/c' , sdkManagerPath , ...args ] ;
138+ }
139+
140+ const child = spawn ( cmd , cmdArgs , {
128141 stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
129142 env : {
130- ...process . env ,
131143 JAVA_HOME : process . platform === 'win32' ? `"${ javaPath } "` : javaPath
132144 }
133145 } ) ;
@@ -147,7 +159,7 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st
147159 function handleDataStream ( data : Buffer ) {
148160 const chunk = data . toString ( ) ;
149161 output += chunk ;
150- process . stderr . write ( chunk ) ;
162+ process . stdout . write ( chunk ) ;
151163 }
152164 const acceptBuffer = Buffer . from ( Array ( 10 ) . fill ( 'y' ) . join ( os . EOL ) , 'utf8' ) ;
153165 child . stdin . write ( acceptBuffer ) ;
0 commit comments