Batch file --- Search registry for a key, Find and replace text in text file
Posted on 2004-04-16
Been trawling the net but couldn't find the answer I'm looking for.
I'm trying to automate an uninstallation from a batch file.
Basically I'm looking to write a batch file to perform these functions.
1) Search Win XP registry for the key "DisplayName" and compare if the value is
to what I want. Say I want to find "DisplayName" key with "Paint Shop Pro" value.
To keep searching for "DisplayName" until found the one with the value "Paint Shop Pro".
2) Once found, to store the FullKey path in a variable. Using this path variable, I can
easily read the value of the "UninstallString" key to perform my next command.
I believe the code for reading a registry key's value using REG QUERY is:
for /f "tokens=3" %%p IN ('reg query FULLKEY-PATH-HERE /v UninstallString') do set value=%%p
3) To edit a text file, search for the string "z:\web\files" and replace it with "c:\web\files"
Is throwing in generous EE points for the expert who can provide me with the working codes
[tried and tested] and just a brief description. Hope to be hearing positive news!