Can I use REG_EXPAND_SZ for the locations of shell folders instead of REG_SZ

0

I'm working on re-arranging a number of the shell folders in windows 7 to utilize Dropbox to keep a set of machines in sync.

I'd like to create a .reg file which I can use to update the locations of these folders rather than manually changing them from the UI, but I don't want to rely on the path to the home folder being the same each time.

So my question is, is it possible to replace the REG_SZ values in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders with REG_EXPAND_SZ values specifying an offset from %HOME% instead of an exact path?

Jherico

Posted 2010-05-03T01:38:25.070

Reputation: 204

Answers

1

Gah, ignore the rest of this answer. The registry key you have there is useless. It won't change anything with your shell folders. Heck, there is even a value there:

alt text

You see, The reason that that key existed and shell folder locations were stored in the registry is that they initially were stored there. But since there was a documented way to get at them this was an implementation detail. Explorer might still update those values for you as a convenience since a great many applications are incorrectly relying on that key but you should never use it, anyway. Back to the topic, since this is just a static list reflecting (or not) what Explorer stores elsewhere changes there won't affect the systen in any way. Explorer simply doesn't care about it. Image you write where you are on a slip of paper every time you go somewhere. Do you magically pop up in another location when someone else writes on that paper?


As for REG_SZ to REG_EXPAND_SZ: Try it, but don't assume that it will magically work. The registry itself doesn't care about REG_SZ and REG_EXPAND_SZ–that's all done by the application reading the data. And since this value is a REG_SZ I'm guessing that you can't just replace it with REG_EXPAND_SZ and have it work.

Joey

Posted 2010-05-03T01:38:25.070

Reputation: 36 381

1

Just a suggestion:

Instead of writing an adaptable .reg file, why don't you write a .bat file instead?
The .bat file can use environment variables, as well as change the registry.

See the following articles:

Managing the Windows Registry from the Command Prompt with Reg.exe
Batch files - Use REGEDIT to add, read or delete registry values

harrymc

Posted 2010-05-03T01:38:25.070

Reputation: 306 093