Link to home
Start Free TrialLog in
Avatar of kulisncc
kulisncc

asked on

Errorlevel in Script not Functioning

I am trying to run the following batch script and it is not doing what I want it to. I want it to check to see if the version of a program exists in the registry and if it does, then uninstall it and install a later version but if it does not exists in the registry then just quit. The problem I am having is that it installs no matter if the version exists in the registry or not. I then want to creae a computer configuration start up script to push this out. Here is the code:
@echo off

REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\FFD0D1F8C889BA64A87750A079B96B05\InstallProperties /v DisplayVersion | Find "DisplayVersion      REG_SZ  7.5.087"

If ErrorLevel 0 goto Exists
If ErrorLevel 1 goto Not_Exists

:Exists

msiexec.exe /m /x "\\myserver\old.msi" /qn

msiexec.exe /i "\\myserver\new.msi" /qn /norestart


:Not_Exists

Echo EC 7.5.087 Does Not Exists

@pause

exit

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of johnb6767
johnb6767
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kulisncc
kulisncc

ASKER

ahhh geez - I should've thought of that. I will give it a shot and let  you know. Thanks dude.
GL with it..  :)
it worked. thanks
Anytime.. :)