• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

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

0
kulisncc
Asked:
kulisncc
  • 3
  • 2
1 Solution
 
johnb6767Commented:
 
If %ErrorLevel%==0 goto Exists  
If %ErrorLevel%==1 goto Not_Exists  
 
0
 
kulisnccAuthor Commented:
ahhh geez - I should've thought of that. I will give it a shot and let  you know. Thanks dude.
0
 
johnb6767Commented:
GL with it..  :)
0
 
kulisnccAuthor Commented:
it worked. thanks
0
 
johnb6767Commented:
Anytime.. :)
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now