Search code examples
windowspowershelladb

-p in powershell from adb


Hey im trying to do a screenshot from "Mobilephone" from the terminal I can pull and push normally but when I use the command

.\adb exec-out screencap -p > ./pic3.png

The png cant open


Solution

  • As of this writing (PowerShell 7.2.2), PowerShell's > operator is fundamentally incapable of capturing raw bytes (binary output) - see this answer for more information.

    The simplest workaround is to call via cmd.exe, whose > operator does support raw byte streams:

    cmd /c 'adb exec-out screencap -p > .\pic3.png'
    

    The alternative is to save the screenshot directly to a file on the Android device (syntax gleaned from here), and download it afterwards, as you show in your own answer.

    .\adb shell screencap ./pic3.png