nav2567
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-B4 847CA8E23C exists in HKLM, run msiexec /x {7B4192A1-84C4-4E90-A31B-B 4847CA8E23 C} /qn
I need to do that in a bat script. Please advise how to do it.
Many thanks.
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-B4
I need to do that in a bat script. Please advise how to do it.
Many thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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\SOFTWA RE\Wow6432 Node\Micro soft\Windo ws\Current Version\Un install\{7 B4192A1-84 C4-4E90-A3 1B-B4847CA 8E23C}]
"InstallLanguage"=dword:00 000409
"UninstallString"="msiexec .exe /x {7B4192A1-84C4-4E90-A31B-B 4847CA8E23 C} /qn"
"AuthorizedCDFPrefix"=""
"Comments"=""
"Contact"=""
"DisplayVersion"="10.3.8.7 294"
"HelpLink"=hex(2):68,00,74 ,00,74,00, 70,00,73,0 0,3a,00,2f ,00,2f,00, 63,00,6c,0 0,\
69,00,63,00,6b,00,2e,00,6b ,00,61,00, 73,00,70,0 0,65,00,72 ,00,73,00, 6b,00,79,\
00,2e,00,63,00,6f,00,6d,00 ,2f,00,3f, 00,68,00,6 c,00,3d,00 ,65,00,6e, 00,26,00,\
6c,00,69,00,6e,00,6b,00,3d ,00,73,00, 75,00,70,0 0,70,00,6f ,00,72,00, 74,00,26,\
00,70,00,69,00,64,00,3d,00 ,6b,00,65, 00,73,00,2 6,00,76,00 ,65,00,72, 00,73,00,\
69,00,6f,00,6e,00,3d,00,31 ,00,30,00, 2e,00,33,0 0,2e,00,30 ,00,2e,00, 31,00,30,\
00,30,00,31,00,30,00,00,00
"HelpTelephone"=""
"InstallDate"="20180720"
"InstallLocation"="C:\\Pro gram Files (x86)\\xyz\\xyz 10 for Windows SP2\\"
"InstallSource"="C:\\Windo ws\\TEMP\\ KAVREM~1\\ DA5E2A~1\\ EXEC\\"
"NoRemove"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="xyz"
"Readme"=""
"Size"=""
"EstimatedSize"=dword:0003 58c4
"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:00000 00a
"VersionMinor"=dword:00000 003
"WindowsInstaller"=dword:0 0000001
"Version"=dword:0a030000
"Language"=dword:00000409
"DisplayName"="xyz 10 for Windows"
Do you think the below will work?
reg query "HKEY_LOCAL_MACHINE\SOFTWA RE\Wow6432 Node\Micro soft\Windo ws\Current Version\Un install\{7 B4192A1-84 C4-4E90-A3 1B-B4847CA 8E23C" >NUL 2>&1 && (msiexec /x {7B4192A1-84C4-4E90-A31B-B 4847CA8E23 C} /qn
[HKEY_LOCAL_MACHINE\SOFTWA
"InstallLanguage"=dword:00
"UninstallString"="msiexec
"AuthorizedCDFPrefix"=""
"Comments"=""
"Contact"=""
"DisplayVersion"="10.3.8.7
"HelpLink"=hex(2):68,00,74
69,00,63,00,6b,00,2e,00,6b
00,2e,00,63,00,6f,00,6d,00
6c,00,69,00,6e,00,6b,00,3d
00,70,00,69,00,64,00,3d,00
69,00,6f,00,6e,00,3d,00,31
00,30,00,31,00,30,00,00,00
"HelpTelephone"=""
"InstallDate"="20180720"
"InstallLocation"="C:\\Pro
"InstallSource"="C:\\Windo
"NoRemove"=dword:00000001
"NoRepair"=dword:00000001
"Publisher"="xyz"
"Readme"=""
"Size"=""
"EstimatedSize"=dword:0003
"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:00000
"VersionMinor"=dword:00000
"WindowsInstaller"=dword:0
"Version"=dword:0a030000
"Language"=dword:00000409
"DisplayName"="xyz 10 for Windows"
Do you think the below will work?
reg query "HKEY_LOCAL_MACHINE\SOFTWA
Yes, but a couple of characters seem to be missing, I think it should be:
»bp
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)
»bp
HKLM\SOFTWARE\Wow6432Node\ Microsoft\ Windows\Cu rrentVersi on\Uninsta ll and HKLM\SOFTWARE\Microsoft\Wi ndows\Curr entVersion \Uninstall are the keys to query
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