private String writeEmulatorStartScriptWindows ( ) throws MojoExecutionException { String filename = SCRIPT_FOLDER + "\\android-maven-plugin-emulator-start.vbs" ; File file = new File ( filename ) ; PrintWriter writer = null ; try { writer = new PrintWriter ( new FileWriter ( file ) ) ; // command needs to be assembled before unique window title since it parses settings and sets up parsedAvd // and others. String command = assembleStartCommandLine ( ) ; String uniqueWindowTitle = "AndroidMavenPlugin-AVD" + parsedAvd ; writer . println ( "Dim oShell" ) ; writer . println ( "Set oShell = WScript.CreateObject(\"WScript.shell\")" ) ; String cmdPath = System . getenv ( "COMSPEC" ) ; if ( cmdPath == null ) { cmdPath = "cmd.exe" ; } String cmd = cmdPath + " /X /C START /SEPARATE \"\"" + uniqueWindowTitle + "\"\" " + command . trim ( ) ; writer . println ( "oShell.run \"" + cmd + "\"" ) ; } catch ( IOException e ) { getLog ( ) . error ( "Failure writing file " + filename ) ; } finally { if ( writer != null ) { writer . flush ( ) ; writer . close ( ) ; } } file . setExecutable ( true ) ; return filename ; }
Writes the script to start the emulator in the background for windows based environments .