Tuesday, 30 June 2015

Query registry via command line to detect whether program is installed or not


Windows 7/8


You want to check if a program is installed or not on all workstation in the organization.


In this example I will check if Trend Micro v9 anti-virus is installed on all PC's and log results to the file.

echo off

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\TrendMicro\Wofie\CurrentVersion" /v InstallResult
if %errorlevel%==1 (goto NotInstalled) else (goto End)
:: If errorlevel returns 1, the key is not present

echo "%date%-%TIME% - Trend not installed on %computername%" >> \\host\trend_install_log\log.txt


1. Save file as trend-install-log.bat
2. Create new group policy object
3. In Computer configuration > Policies > Windows Settings > Scripts > Startup
add above batch file.
4. Link policy to workstations OU

Make sure that "trend_install_log" share has security set to allow "Domain computers" to read&write.

You can actually not only log the status to the txt file, but also automatically install your application, in my case Trend.
Add before :End below line:

No comments:

Post a Comment