Link to home
Start Free TrialLog in
Avatar of nav2567
nav2567Flag for United States of America

asked on

Detect a software existence in the registry in a Windows batch script

Hello,

I need to write a script to detect a particular software guid exists in the registry on computers and run particular msiexec command line to uninstall it.  

For example, if 7B4192A1-84C4-4E90-A31B-B4847CA8E23C exists in HKLM, run msiexec /x {7B4192A1-84C4-4E90-A31B-B4847CA8E23C} /qn

I need to do that in a bat script.  Please advise how to do it.  

Many thanks.
Avatar of Bill Prew
Bill Prew

Where in HKLM specifically will that exist?

You can use REG QUERY in  a BAT script to check for it's existence, but you need to know the full path to it.


»bp
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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 nav2567

ASKER

Thank you.  I did a search in the registry and the location to detect the guid looks promising - please see below.

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{7B4192A1-84C4-4E90-A31B-B4847CA8E23C}]
"InstallLanguage"=dword:00000409
"UninstallString"="msiexec.exe /x {7B4192A1-84C4-4E90-A31B-B4847CA8E23C} /qn"
"AuthorizedCDFPrefix"=""
"Comments"=""
"Contact"=""
"DisplayVersion"="10.3.8.7294"
"HelpLink"=hex(2):68,00,74,00,74,00,70,00,73,00,3a,00,2f,00,2f,00,63,00,6c,00,\
  69,00,63,00,6b,00,2e,00,6b,00,61,00,73,00,70,00,65,00,72,00,73,00,6b,00,79,\
  00,2e,00,63,00,6f,00,6d,00,2f,00,3f,00,68,00,6c,00,3d,00,65,00,6e,00,26,00,\
  6c,00,69,00,6e,00,6b,00,3d,00,73,00,75,00,70,00,70,00,6f,00,72,00,74,00,26,\
  00,70,00,69,00,64,00,3d,00,6b,00,65,00,73,00,26,00,76,00,65,00,72,00,73,00,\
  69,00,6f,00,6e,00,3d,00,31,00,30,00,2e,00,33,00,2e,00,30,00,2e,00,31,00,30,\
  00,30,00,31,00,30,00,00,00
"HelpTelephone"=""
"InstallDate"="20180720"
"InstallLocation"="C:\\Program Files (x86)\\xyz\\xyz 10 for Windows SP2\\"
"InstallSource"="C:\\Windows\\TEMP\\KAVREM~1\\DA5E2A~1\\EXEC\\"
"NoRemove"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="xyz"
"Readme"=""
"Size"=""
"EstimatedSize"=dword:000358c4
"URLInfoAbout"="https://click.xyz/?hl=en&link=company_account&pid=kes&version=10.9.0.10010"
"URLUpdateInfo"="https://click.xyz.com/?hl=en&link=update_distributive&pid=kes&version=10.9.0.10010"
"VersionMajor"=dword:0000000a
"VersionMinor"=dword:00000003
"WindowsInstaller"=dword:00000001
"Version"=dword:0a030000
"Language"=dword:00000409
"DisplayName"="xyz 10 for Windows"


Do you think the below will work?

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{7B4192A1-84C4-4E90-A31B-B4847CA8E23C" >NUL 2>&1 && (msiexec /x {7B4192A1-84C4-4E90-A31B-B4847CA8E23C} /qn
Yes, but a couple of characters seem to be missing, I think it should be:

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{7B4192A1-84C4-4E90-A31B-B4847CA8E23C}" >NUL 2>&1 && (msiexec /x {7B4192A1-84C4-4E90-A31B-B4847CA8E23C} /qn)

Open in new window


»bp
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall and HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall are the keys to query