Re: PSA: Batch script mirroring Android on the desktop over Wi-Fi (without USB)
Maria Sophia <[email protected]> Mon, 15 Jun 2026 14:31:52 -0500
| Newsgroups | alt.comp.os.windows-11,alt.msdos.batch,alt.comp.microsoft.windows |
|---|---|
| Organization | BWH Usenet Archive (https://usenet.blueworldhosting.com) |
| Message-ID | <[email protected]> |
Maria Sophia wrote: > In addition, I was able to figure out a way to eliminate the scrcpy > console, where I had been using Herbert Kleebauer's ShowWin() previously. In case folks have forgotten, this is the venerable ShowWin() solution which Herbert Kleebaurer kindly provided many years ago & which works well. I used Herbert's method until I realized there was a default "no-console" method for launching scrcpy, where the difference in the two methods are a. The ShowWin() method flashes and then hides the console from view b. The VBS no-console method launches scrcpy without a console window For the record, here's Herbert's ShowWin() method which has worked for years where this is the version I used with USB (before adb Wi-Fi). @echo off REM REM Download screencopy onto your PC <https://scrcpy.org/> REM Set Android "Developer Options" "USB debugging = On" REM Then plug the Android phone into the USB port of Windows REM Then run "scrcpy -s SERIALNUMBER" on the Win/Mac/Linux PC REM This will mirror Android onto your Win/Mac/Linux PC REM But scrcpy leaves an annoying console behind, by default REM The entire point of this script is to run that one command REM But WITHOUT leaving an empty console behind on Windows. REM REM C:\app\editor\android\scrcpy\showwin.bat REM adb mdns services REM List of discovered mdns services REM netstat -ano -p tcp | findstr "192.168.1.3" REM TCP 192.168.1.2:15919 192.168.1.3:41913 ESTABLISHED 7904 REM cd /d "c:\app\editor\android\scrcpy" REM embedded certificate block is an executable encoded within the batch file! REM Extract embedded executable from script using certutil decode REM Reads the batch file itself (%~f0) as encoded source content REM Decodes certificate block at the bottom and writes showwin.exe REM -f forces overwrite if showwin.exe already exists REM Output is suppressed using >nul to keep console clean REM showwin.exe is used to hide the console window temporarily REM The batch file launches scrcpy to mirror your phone. REM Normally, this leaves a blank console window hanging open. REM The command showwin.exe 0 is run right after launching scrcpy. REM This executable finds the console window and hides it from view. REM When you're done and close scrcpy, the script runs showwin.exe 5 REM which makes the console visible again briefly to clean up. REM Showwin searches for the window with the class "ConsoleWindowClass" REM (that's how Windows identifies command windows). REM Uses a system call (like ShowWindow() in Win32 API) to make it invisible. REM It doesn't actually kill or close the window. REM It just makes it vanish visually while scrcpy runs REM So youre left with a clean screen showing only your mirrored phone. certutil -f -decode %~f0 showwin.exe>nul REM Port 5555 was needed when you established adb connections over USB REM And then you disconnected the USB cable to subsequently work on Wi-Fi REM But as of Android 11 or 12, you can establish the connection over Wi-Fi REM But that "Developer option" "Wireless debugging" port is assigned by Android! REM So you have to get it on Android or on Windows to know what it is REM adb connect 192.168.1.3:5555 REM You can get the current port from the following command REM c:\> netstat -ano -p tcp | findstr "192.168.1.3" REM REM maybe we do NOT need this command after all??? REM adb connect 192.168.1.3:41913 REM :: now we hide console window showwin.exe 0 REM REM scrcpy --always-on-top --tcpip=192.168.1.3:5555 REM Maybe we can then remove the IP:PORT after all??? REM scrcpy --always-on-top --tcpip=192.168.1.3:41913 REM We don't really need --always-on-top after all??? REM scrcpy --always-on-top REM scrcpy REM scrcpy -s adb-SERIAL_adb-tls-connect._tcp. REM scrcpy -s 192.168.1.21 REM scrcpy -s SERIAL REM scrcpy -s SERIAL -K is dangerous to Android REM scrcpy -s SERIAL --keyboard=sdk is less dangerous REM scrcpy --prefer-text REM scrcpy -s RFCT21AMDZE --keyboard=sdk :: after scrcpy is closed we show console window again :: scrcpy-noconsole.vbs :: start "" /b scrcpy -s SERIAL -K. :: scrcpy -s SERIAL -K --mouse-bind=++++ showwin.exe 5 REM del showwin.exe goto :eof REM -----BEGIN CERTIFICATE----- TVpgAQEAAAAEAAAA//8AAGABAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAoAAAAA4fug4AtAnNIbgBTM0hTmljZSB0byBtZWV0IHNvbWVi b2R5IHdobyBpcyBzdGlsbCB1c2luZyBET1MsDQpidXQgdGhpcyBwcm9ncmFtIHJl cXVpcmVzIFdpbjMyLg0KJFBFAABMAQEAUHmlNgAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAA== -----END CERTIFICATE----- -- If something takes 20 steps, we reduce it in half, and if it takes 2 steps, we still reduce it in half, until everything we do, is a single quick step.