We help IT Professionals succeed at work.
Get Started

Batch registry query to take action on condition

hpops asked
Last Modified: 2012-08-16

I have a batch file I'm working on that queries the registry to see if a particular version of software is installed. I think I'm on the right track but am having trouble getting it to evaluate different versions. It seems to detect them all and even if nothing is found in the registry it processes each line.

Any ideas on how I can fix this?

FOR /F "tokens=2*" %%A IN ('REG.EXE QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Sunbelt Software\Sunbelt Enterprise Agent" /V "Version" 2^>NUL ^| FIND "REG_SZ"') DO SET VIPREVer=%%B
If VIPREVer == "3.1.2848" goto 312848
If VIPREVer == "4.0.3907" goto 403907 
If VIPREVer == "4.0.4205" goto 404205 

goto eof

msiexec /x "\\Server1\Applications\Sunbelt\Desktops\SBEAgent-HPEaton_Desktops.msi" /QN

msiexec /x "\\Server1\Applications\Sunbelt\HPE_Desktops_4.0.4205\SBVEA_403907.msi" /QN

msiexec /x "\\Server1\Applications\Sunbelt\HPE_Desktops_4.0.4205\SBVEA_401_EN-HPE Desktops.msi" /QN


Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE