user12531529
user12531529

Reputation:

How to run AVD emulator from .bat without a console window?

I want to create a shortcut to run AVD emulator without opening Android Studio. So I use a .bat file which contains next line:

emulator @Pixel_2_API_29

When running it I, of course, get a console window, which I really don't need:

cmd

If I close it, emulator also closes. Is there any way to run it in background or something similar just to get a running emulator without any console windows (the same behaviour can be achieved if you run emulator from Android Studio and close it immideately)?

Upvotes: 3

Views: 2412

Answers (2)

Io-oI
Io-oI

Reputation: 2565


enter image description here


This is a hybrid cmd/js/vbs/batch and this code can do this job for you, just save as .cmd and enjoy!


<!-- :
@echo off && mode 050,03 && title <nul && title .\%~nx0 && for /f ^tokens^=* %%i in ('
%__APPDIR__%wScript.exe "%~dpnx0?.wsf" @Pixel_2_API_29 ^& cls ') do exit /b 2>nul >nul
--> <job> <script language = "vbscript"> Set WshShell =CreateObject( "WScript.Shell" )
WshShell.Run chr(34)&"%userprofile%\AppData\Local\Android\Sdk\emulator\emulator.exe"&_
Chr(34)&WScript.Arguments(0)&Chr(34), 0, False: Set WshShell = Nothing </script></job>

  • Obs.:

You can read more about hybrid bat in this link, and see some sample code/files here.


  • For using with arguments, just add quote in for loop bat session:
"arg1 arg2 ag3" <==> " -memory 4096" obs.: 3rd line in code!

<!-- :
@echo off && mode 050,03 && title <nul && title .\%~nx0 && for /f ^tokens^=* %%i in ('
%__APPDIR__%wScript.exe "%~dpnx0?.wsf" @Pixel_2_API_29 " -memory 4096"^>nul')do exit/b
--> <job> <script language = "vbscript"> Set WshShell =CreateObject( "WScript.Shell" )
WshShell.Run chr(34)&"%userprofile%\AppData\Local\Android\Sdk\emulator\emulator.exe"&_
Chr(34)&WScript.Arguments(0)&Chr(34)&Chr(34)&WScript.Arguments(1)&Chr(34), 0, False:
Set WshShell=Nothing</script></job>

Upvotes: 7

somebadhat
somebadhat

Reputation: 779

Look into running the batch as a service

If you can live with the console window:

Create a shortcut to the batch file. Right click on the shortcut - Properties - Run: Minimized

screenshot change shortcut properties

screenshot change shortcut properties run minimized

Upvotes: 0

Related Questions