@@ -161,7 +161,7 @@ export class Electron extends SdkObject {
161161 return controller . run ( async progress => {
162162 let app : ElectronApplication | undefined = undefined ;
163163 // --remote-debugging-port=0 must be the last playwright's argument, loader.ts relies on it.
164- const electronArguments = [ '--inspect=0' , '--remote-debugging-port=0' , ...args ] ;
164+ let electronArguments = [ '--inspect=0' , '--remote-debugging-port=0' , ...args ] ;
165165
166166 if ( os . platform ( ) === 'linux' ) {
167167 const runningAsRoot = process . geteuid && process . geteuid ( ) === 0 ;
@@ -195,6 +195,16 @@ export class Electron extends SdkObject {
195195 // Packaged apps might have their own command line handling.
196196 electronArguments . unshift ( '-r' , require . resolve ( './loader' ) ) ;
197197 }
198+ let shell = false ;
199+ if ( process . platform === 'win32' ) {
200+ // On Windows in order to run .cmd files, shell: true is required.
201+ // https://github.com/nodejs/node/issues/52554
202+ shell = true ;
203+ // On Windows, we need to quote the executable path due to shell: true.
204+ command = `"${ command } "` ;
205+ // On Windows, we need to quote the arguments due to shell: true.
206+ electronArguments = electronArguments . map ( arg => `"${ arg } "` ) ;
207+ }
198208
199209 // When debugging Playwright test that runs Electron, NODE_OPTIONS
200210 // will make the debugger attach to Electron's Node. But Playwright
@@ -208,9 +218,7 @@ export class Electron extends SdkObject {
208218 progress . log ( message ) ;
209219 browserLogsCollector . log ( message ) ;
210220 } ,
211- // On Windows in order to run .cmd files, shell: true is required.
212- // https://github.com/nodejs/node/issues/52554
213- shell : process . platform === 'win32' ,
221+ shell,
214222 stdio : 'pipe' ,
215223 cwd : options . cwd ,
216224 tempDirectories : [ artifactsDir ] ,
0 commit comments