May 10, 2012

Windows Registry file (.reg) doesn't register key

It was a nice test for me. I needed to give a .reg file for a collegue of mine (its a long story) to recreate a setting for something we're doing. Long story short - I needed to add a path under a certain key so I did the following:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Key1\SubKey1]
"PathKey1"="C:\SomeFolder\SomeSubFolder\SomeExecutable.exe"
When I ran it on my PC to verify it's working I saw it created the keys all the way to the "SubKey1" but the string value PathKey1 wasn't added. Can you say what the problem was? I wasn't sure as well. Then I've found you have a nifty little menu option in registry that says "Export" and it will create the reg file for you. I ran it and out of curriosity I opened the file in Notepad to see what was I missing. The thing is that RegEdit want to have the "\" escaped with another "\" so the successfull reg file will be:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Key1\SubKey1]
"PathKey1"="C:\\SomeFolder\\SomeSubFolder\\SomeExecutable.exe"
The catch here is that no matter RegEdit won't be able to create the String value it will tell you that it succeeded. I will most probably never use to manually add things in Notepad, I'll use Regedit Export functionality now that I know it but be sure to always check that paths added to the registry via .reg file are double escaped. Hope this helps.

2 comments:

Anonymous said...

My coder is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the costs.
But he's tryiong none the less. I've been using
Movable-type on a number of websites for about a year and am concerned about switching to another platform.

I have heard good things about blogengine.net. Is there a way I
can transfer all my wordpress content into it?
Any kind of help would be greatly appreciated!


Also visit my webpage ... click this site

Anonymous said...

Do you mind if I quote a couple of your articles as long as
I provide credit and sources back to your site?

My blog site is in the very same niche as yours and my users would certainly benefit from a lot of the information you provide here.
Please let me know if this ok with you. Cheers!


my web site click this site