@set imagepath= @FOR /F "tokens=3" %%a in ('reg query HKLM\system\currentcontrolset\services\%1 /v imagepath 2^> nul ^| find "imagepath" ') DO @set imagepath=%%a @if defined imagepath ( @echo Dependencies for %imagepath%: @call depends /a0f1c /oc:~svcdep.tmp "%imagepath%" @FOR /F "tokens=1 delims=, skip=1" %%b in ('type ~svcdep.tmp ^| findstr /B /c:"," ^| findstr /V /c:"?" ^| sort') do @echo %%b @del ~svcdep.tmp 2>nul ) else ( @Echo '%1' is not installed or is not a valid service )