Getting a batch file to react to a registry key
I have an issue with an antivirus software package. Our technicians used Ghost to image most of the computers, but didn't follow the procedures for the AV. I have a batch file that will remove the software and re-install it through a GPO. However, once the GPO runs once, we don't want it to continue re-installing over and over.
I have the following line in the file at the end of the removal process:
ECHO Installation of a new registry key..
REG ADD HKLM\SOFTWARE\SAVREINSTALLED /v DATA /t REG_Z
At the beginning of the batch file, I have the following:
ECHO Checking for previous installations...
REM Error Levels 0=Successful, the result compared is different
REM 2=Successful, the result compared is different
REG COMPARE HKLM\SOFTWARE HKLM\SOFTWARE\SAVREINSTALLED
if %errorlevel% equ 1(
Echo SAV already installed, aborting the script
) ELSE Exit
When I run the batch file, it just stops and closes. When I run the REG commands seperately, I get the results I'm looking for (Generating the key, checking it, etc).
Now, I need to tie it all together. I'm not really good at programming, so I'm sure the problem is in how I'm checking the compare function.
Can anyone please help me out here? My only other option isd to individually visit every computer here on campus (over 500)!!!