I'm trying to query a particular registry folder (or whatever you want to call it) to obtain some information.
Particularly the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
folder contains a list of installed software.
The issue is that each software is identified through a random key value like {0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}
instead of the actual software (like Skype
).
This makes it hard to find the Skype
identifier because I need to loop through everything inside this Uninstall
folder and check whether the DisplayName
value corresponds to Skype
(or whatever other application name).
I need to use batch syntax... this is what I have so far but it doesn't behave the same on different computers, maybe I get different variables assigned based on some erroneous formatting of the reg output? I don't know. Can I use a data structure to contain whatever reg
outputs? Anything would work.
@echo off
for /f "tokens=*" %%a in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall') do (
for /f "tokens=2,* delims= " %%b in ('reg query %%a /v Publisher') do (
IF "%%c" == "Skype Technologies S.A." (
for /f "tokens=2,* delims= " %%d in ('reg query %%a /v UninstallString') do (
echo %%e
)
)
)
)
Is there a cleaner and safer way to achieve this in batch?
It seems me more easy to use
reg QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /f "Skype Technologies S.A." /s
as a basis for your batch file. It produces a simple output like following
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D103C4BA-F905-437A-8049-DB24763BBE36}
Publisher REG_SZ Skype Technologies S.A.
End of search: 1 match(es) found.