1
I need a batch loop that should extract a data value and use it in its next command. All registry keys I want to query has been saved into a *.txt file.
Example:
The following command will return the key value, type and data as per below.
COMMAND:
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\01690987922DC9549A63529D22383DDF\InstallProperties /V UninstallString
RESULT:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\01690987922DC9549A63529D22383DDF\InstallProperties
UninstallString REG_EXPAND_SZ MsiExec.exe /X{78909610-D229-459C-A936-25D92283D3FD}
What I want to do is to extract only the data value MsiExec.exe /X{78909610-D229-459C-A936-25D92283D3FD}
and run it as my next command in the for loop.
I have roughly 20 registry keys that I want to query and then run the extracted command. I also want to add silent switches to the msiexec.exe command when it is executed.
I'm very new to batch loops and believe I need to use tokens/delims(?)... not really sure how to get it working.
2Do you need to use the cmd language or can you upgrade to a more capable tool (powershell, python, perl)? – Alien Life Form – 2016-03-23T14:00:14.450
Other methods are OK. We use Windows ADK/MDT for unattended OS/application installations and any form of legacy package should work fine. I reckon powershell would be the best fit if I take my colleagues into consideration. – Heinza – 2016-03-23T14:46:06.060
@AlienLifeForm
cmd
is perfectly capable of such a trivial task ;) – DavidPostill – 2016-03-23T18:54:44.553@AlienLifeForm I also have cygwin as well. I just haven't gotten around to learning powershell. – DavidPostill – 2016-03-24T08:25:02.533