[HTC EVO 3D] viddywell:
I wanted to provide something that I thought would be beneficial to the community as a whole. I see a lot scripts utilizing ADB (for example, the TWRP Flash Tool) that can benefit from further error checking - making them more user friendly, catching errors, and allowing for more direct troubleshooting.

So, what I put together is a "shell" if you will to wrap future ADB batch files in. This shell does a number of things including:

Capturing whether a device is found or not

Capturing the state of the device (bootloader or device)

Checking for running instances of HTC Sync

Checking for running instances of Easy Tether

Providing relevant information to the user to help in troubleshooting

UPDATE: Option to create a system report upon failure that can be be shared with forum for troubleshooting. Currently capturing Windows Version, Running Apps, and Running Services

UPDATE: Additional information to user report - ADB Version and files in directory where script is executed

@echo off
:top
set reportrun=0
color
REM Check for HTC Sync
tasklist | findstr htcUPCTLoader >nul
If %errorlevel% equ 0 (set htcsync=1) ELSE (set htcsync=0)

REM Check for Easy Tether
tasklist | findstr easytthr >nul
If %errorlevel% equ 0 (set easyt=1) ELSE (set easyt=0)

REM Check for device connection
adb devices | findstr /r "device$" >nul
If %errorlevel% neq 0 goto devmis

REM Get device state (this can be used as an error checking variable later if necessary)
for /f %%a in ('adb get-state') do @set state=%%a

cls
Echo Device found! In %state% mode.
Pause

REM Your code HERE

exit
:devmis
set sys=n
color 4f
CLS
Echo No device found - please check the following items:
Echo.
If %htcsync% equ 1 Echo - HTC Sync found - Please try disabling
If %easyt% equ 1 Echo - Easy Tether found - Please try disabling
Echo - Device is connected
Echo - USB Debugging is enabled
Echo.
Echo ------------------------------------------
Echo We can collect further information to assist with troubleshooting.
Echo This will query your system and generate a report with information
Echo about your computer. You will be given a chance to review and edit
Echo the collected information and share via copy/paste. No information
Echo will be shared without your consent.
Echo.
Set /p sys=Would you like to collect system information (y/n):
if /I %sys% equ y GOTO sysinfo
if /I %sys% equ yes sysinfo
goto tryagain
:tryagain
cls
echo.
If %reportrun% equ 1 (echo Text from window can be copied to forum for troubleshooting)

Echo Press any key to try running script again
Pause >nul
goto top

:sysinfo
Echo System information - Generated on %date% at %time% >report.txt
Echo ----------------------------------------------------- >>report.txt
echo ADB Version: >>report.txt
adb version >>report.txt
Echo. >>report.txt

echo Windows Version: >>report.txt
ver >>report.txt
Echo. >>report.txt

Echo Files in Directory of Script Execution >>report.txt
dir /b >>report.txt
Echo. >>report.txt

Echo Running Applications: >>report.txt
tasklist >>report.txt
Echo. >>report.txt

Echo Started Services: >>report.txt
sc query >>report.txt

start "" report.txt
set reportrun=1
goto tryagain

Here are screenshots of what a user would see -

Success:

Failure (1) - HTC Sync and Easy Tether are dynamic and will only show if found on system :

Failure (2):

I've also attached a sample of the report to be generated (report.txt) and the original version of the script for posterity (version 1 script.txt)

This is just a start - I'd love to add more to make this more helpful. Further ideas that I haven't implemented here include:

Checking for the "Android Phone" in device manager

Linking to relevant wiki pages for enabling USB Debugging if device isn't found

Create an error log that can be shared with developers

I can't be too much help with the Android development side of things but I can certainly help to build this out further if it's helpful to other developers. I welcome you to integrate it into your code if you'd like. Please don't hesitate to let me know if there's anything you'd like to capture from a Windows side or if I can assist with slotting your code into this shell.