Wednesday 16 February 2011

Using ADB.EXE to Capture a Bug Report (useful way to capture phone properties and logs)

I created the batch file "BugReport.cmd" so I could use the "Android Debug Bridge" to capture debug information into a date stamped filename. This captures firmware build versions, the system log (logcat), System properties, service states and much more.

First off though you need to install "ADB.EXE" and any dlls it might require. I tested this on Windows 7 (64 Bit) but can't see why this wouldn't work on WINXP or even WIN2000.

If you have install Samsung KIES or HTC Sync (or any similar sync software) you will already have a version of "ADB.EXE" installed, its easiest to either install the batch file into the same directory or make sure that the directory is listed by the "PATH" environment variable. If you can't find it you'll have to install the SDK etc.

This is "BugReport.CMD":

@echo off
echo []--------------------------------------------------------------------[]
echo ^| Generate Andoid Bug Report Version 11.047a (C) by Dennis Bareis 2011 ^|
echo []--------------------------------------------------------------------[]

@rem *** Find AD.EXE or abort *********************************************
set BatchFileDir=%~dp0
set AdbExe=%BatchFileDir%ADB.EXE
if exist "%AdbExe%" goto FoundAdbExe
set AdbExe=%CD%\ADB.EXE
if exist "%AdbExe%" goto FoundAdbExe
set AdbExe=
for %%f in ("AdbExe") do set AdbExe=%%~$PATH:f
if not "%AdbExe%" == "" FoundAdbExe
echo ERROR: Could not find "ADB.EXE" (have you installed it?)
echo To find ADB.EXE this script:
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo (1) Looks in the same directory as the batch file ("%BatchFileDir%)
echo (2) Looks in the current directory (%CD%)
echo (3) Looks in the PATH, that is one of the following directories: %PATH%
goto :EOF
echo USING ADB: "%AdbExe%"

@rem *** Wait for Android to connect and display its setial number *******
set LogDir=%BatchFileDir%$BugReports$
set TmpFile=%LogDir%\SerialNumber.tmp.txt
del "%TmpFile%" >nul 2>&1
md "%LogDir%" >nul 2>&1
echo Waiting for Android Device (it must have "USB Debugging" turned ON)
"%AdbExe%" wait-for-device
"%AdbExe%" get-serialno > "%TmpFile%"
set SerialNumber=
set /p SerialNumber= < "%TmpFile%"
echo Found Android Device with serial number "%SerialNumber%"

set ReportFile=%LogDir%\Android Bug Report - %SerialNumber% (%date:/=-% @ %time::=_%).txt
echo GENERATING: "%ReportFile%"
"%AdbExe%" bugreport > "%ReportFile%" 2>&1
echo Generated Bug report, opening in notepad.
start "" "%LogDir%"
start "" notepad.exe "%ReportFile%"

1 comment:

nemosfate said...

Worked perfectly thank you, running win XP btw.