@@ -12,7 +12,16 @@ const NULL_ROOT_ELEMENT = /* ps1 */ `$rootElement = $null`;
1212const INIT_ELEMENT_TABLE = /* ps1 */ `$elementTable = New-Object System.Collections.Generic.Dictionary[[string]\`,[AutomationElement]]` ;
1313
1414export async function startPowerShellSession ( this : NovaWindowsDriver ) : Promise < void > {
15- const powerShell = spawn ( 'powershell.exe' , [ '-NoExit' , '-Command' , '-' ] ) ;
15+ const spawnEnv = this . caps . appEnvironment
16+ ? { ...process . env , ...( this . caps . appEnvironment as Record < string , string > ) }
17+ : process . env ;
18+
19+ if ( this . caps . appEnvironment ) {
20+ const keys = Object . keys ( this . caps . appEnvironment as Record < string , string > ) ;
21+ this . log . info ( `Applying appEnvironment variables to PowerShell session: ${ keys . join ( ', ' ) } ` ) ;
22+ }
23+
24+ const powerShell = spawn ( 'powershell.exe' , [ '-NoExit' , '-Command' , '-' ] , { env : spawnEnv } ) ;
1625 powerShell . stdout . setEncoding ( 'utf8' ) ;
1726 powerShell . stderr . setEncoding ( 'utf8' ) ;
1827
@@ -93,7 +102,10 @@ export async function startPowerShellSession(this: NovaWindowsDriver): Promise<v
93102export async function sendIsolatedPowerShellCommand ( this : NovaWindowsDriver , command : string ) : Promise < string > {
94103 const magicNumber = 0xF2EE ;
95104
96- const powerShell = spawn ( 'powershell.exe' , [ '-NoExit' , '-Command' , '-' ] ) ;
105+ const spawnEnv = this . caps . appEnvironment
106+ ? { ...process . env , ...( this . caps . appEnvironment as Record < string , string > ) }
107+ : process . env ;
108+ const powerShell = spawn ( 'powershell.exe' , [ '-NoExit' , '-Command' , '-' ] , { env : spawnEnv } ) ;
97109 try {
98110 powerShell . stdout . setEncoding ( 'utf8' ) ;
99111 powerShell . stdout . setEncoding ( 'utf8' ) ;
0 commit comments