Powered by GeSHi

Source code for getuninstall.bat

(view source code of getuninstall.bat as plain text)

  1. @ECHO OFF
  2. :: Windows 7 only
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. VER | FINDSTR /R /E /C:" 6\.[01]\.[0-9\.]*\]" >NUL || GOTO Syntax
  5.  
  6. :: Check command line arguments
  7. IF     "%~1"=="" GOTO Syntax
  8. IF NOT "%~2"=="" GOTO Syntax
  9. ECHO "%~1" | FINDSTR /R /C:"[/?]" >NUL && GOTO Syntax
  10.  
  11. SETLOCAL ENABLEDELAYEDEXPANSION
  12. SET Count=0
  13. FOR /F "tokens=*" %%A IN ('REG Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
  14. 	REG Query "%%~A" /F DisplayName /V /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
  15. 	IF NOT ERRORLEVEL 1 (
  16. 		SET /A Count += 1
  17. 		FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F DisplayName    /V /E 2^>NUL ^| FIND /I " DisplayName "')     DO ECHO Program Name      = %%C
  18. 		FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "')  DO ECHO Program Version   = %%C
  19. 		FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F InstallDate    /V /E 2^>NUL ^| FIND /I " InstallDate "')     DO (
  20. 			SET InstallDate=%%C
  21. 			ECHO Install Date      = !InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
  22. 		)
  23. 		FOR /F "tokens=7 delims=\" %%B IN ("%%~A") DO ECHO Unique Identifier = %%B
  24. 		FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F UninstallString /V /E ^| FIND /I " UninstallString "') DO ECHO Uninstall String  = %%C
  25. 		ECHO.
  26. 	)
  27. )
  28.  
  29. WMIC.EXE Path Win32_Processor Get DataWidth 2>NUL | FIND "64" >NUL
  30. IF ERRORLEVEL 1 (
  31. 	ECHO.
  32. 	ECHO %Count% programs found
  33. ) ELSE (
  34. 	SET Count32bit=0
  35. 	FOR /F "tokens=*" %%A IN ('REG Query HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
  36. 		REG Query "%%~A" /F DisplayName /V /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
  37. 		IF NOT ERRORLEVEL 1 (
  38. 			SET /A Count32bit += 1
  39. 			FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F DisplayName    /V /E 2^>NUL ^| FIND /I " DisplayName "')     DO ECHO Program Name      = %%C
  40. 			FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "')  DO ECHO Program Version   = %%C
  41. 			FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F InstallDate    /V /E 2^>NUL ^| FIND /I " InstallDate "')     DO (
  42. 				SET InstallDate=%%C
  43. 				ECHO Install Date      = !InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
  44. 			)
  45. 			FOR /F "tokens=7 delims=\" %%B IN ("%%~A") DO ECHO Unique Identifier = %%B
  46. 			FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F UninstallString /V /E ^| FIND /I " UninstallString "') DO ECHO Uninstall String  = %%C
  47. 			ECHO.
  48. 		)
  49. 	)
  50. 	ECHO.
  51. 	ECHO     %Count% 64-bit programs and !Count32bit! 32-bit programs found
  52. )
  53.  
  54. ENDLOCAL
  55. GOTO:EOF
  56.  
  57.  
  58. :Syntax
  59. ECHO.
  60. ECHO GetUninstall.bat,  Version 2.00 for Windows Vista and later
  61. ECHO List or search uninstall command lines
  62. ECHO.
  63. ECHO Usage:    GETUNINSTALL.BAT  "filter"
  64. ECHO.
  65. ECHO Where:    "filter"    narrows down the search result to programs whose
  66. ECHO                       uninstall data contains the string "filter"
  67. ECHO.
  68. ECHO Example:  GETUNINSTALL.BAT "Adobe Reader"
  69. ECHO.
  70. ECHO Written by Rob van der Woude
  71. ECHO http://www.robvanderwoude.com
  72.  
  73. :: Set return code for Windows NT 4 or later
  74. IF "%OS%"=="Windows_NT" COLOR 00
  75.