Finding and replacing text in registry file with quotes and paths and spaces.

Home Forums Scripting DOS Command Shell Finding and replacing text in registry file with quotes and paths and spaces.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    HelpWantI
    Member
    #154449

    Hi Everyone, I’m new here – please be nice.

    I want to only use a Batch File for the purpose of replacing something like:

    [HKEY_LOCAL_MACHINESOFTWAREMYPROGRAM]
    “PathToProgram”=”C:\Program Files\MyDirectory\MyProgram”

    with this:

    [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMYPROGRAM]
    “PathToProgram”=”C:\Program Files (x86)\MyDirectory\MyProgram”

    Some lines are also set out as:
    “PathToProgram”=”C:Program Files (x86)MyDirectoryMyProgram”
    so it needs to be able to change these also.

    So here I am looking for “Program Files” to be replaced (if found) with “Program Files (x86)” and “HKEY_LOCAL_MACHINESOFTWAREMYPROGRAM” with “HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMYPROGRAM”

    Doing this is allowing the exported registry file to be changed so it can be imported into the registry on a x64 system (and still work).

    Because it is a registry file, it must be able to work with quotes (“), spaces in paths, and blank lines kept intact. Pretty tricky, I know.

    Another post on this forum has come close, but doesn’t work with quotes and spaces (I can’t post the link until I post 5 or more times..?)

    Batch Files are my only option for doing this please – I don’t know any other programming language, and relying on third party programs of vbs scripts etc to do this for me are not an option. Batch File solutions only please would be most welcome.

    Oh, it would be great if the reverse would work also:

    [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMYPROGRAM]
    “PathToProgram”=”C:\Program Files (x86)\MyDirectory\MyProgram”

    with this:

    [HKEY_LOCAL_MACHINESOFTWAREMYPROGRAM]
    “PathToProgram”=”C:\Program Files\MyDirectory\MyProgram”

    Thanks so much in advance if anybody can help me.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.