Jump to content

Environment Variables


Quisquose

Recommended Posts

Does anybody know if there is a System variable value for Local Settings?

I've been driving myself crazy trying to find a solution to getting an environmental variable value for this particular folder.

After many, many hours of searching, I found some web sites that listed a more comprehensive collection of variables (rather than just the usual suspects that most sites trot out) but many of these lesser known variables (such as %recent% and %cookies%) simply did not work.

Annoyingly, there is a variable for the Application Data folder (%AppData%) and this works fine, so I don't know why there isn't one for Local Data.

I thought about creating my own system variable to achive the same end, however I can't figure out how to define the variable without hard-coding the path to decribe it (which defeats the purpose of the reson why I want to use a variable in the first place).

Anyone have any ideas?

Link to comment
Share on other sites


You can create your own environment variable using [ExtraFileEdits] and the RyanVM Integrator

I made one for my Vista Sidebar AddOn http://www.wincert.net/forum/index.php?showtopic=485

Edit your i386\HIVEDEF.INF file... Look for HKCU,"Environment","TMP",0x00020000,"%TEMP_DIR%"

and just add something under it like HKCU,"Environment","VAIO",0x00020000,"%SYSTEMDRIVE%\VAIO"

NOTE: this will not take effect untill you LogIn for the first time so you cant make a inf addon with the variable you just created...

You can also make a INF addon to add your var.

The Brown is the name of your Variable and the Green is the Path to the folder

You also might want to add a semicolon and your enviroment var name between Percentage symbols like ;%VAIO% to i386\HIVESYS.INF HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path",0x00020002,"%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%VAIO%"

Edited by ricktendo64
Link to comment
Share on other sites

Why not simply use: "%userprofile%\local settings" ?
Usually a safe guess, however some sick and evil person could have relocated it. Probably want to have a look at
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
"Local Settings"=

(or if not current user, replace with the appropriate S-whatever). If you want to be complete as possible you should export that key to a variable.

Only problem is while browsing for the above, I found "local settings" hard coded quite a bit. Maybe explains why it isn't an environment variable.

Edited by JoeMSFN
Link to comment
Share on other sites

Thanks everyone for the replies! :yes:

"Why not simply use: "%userprofile%\local settings""

Because that's not a variable.

Hard-coding half of the path provides no benefit over hard-coding the entire path (if the path gets changed).

You can create your own environment variable using [ExtraFileEdits] and the RyanVM Integrator

Whoa! I never even knew things like this were possible! :blink: I will look into this. Thank you very much for the heads up.

I found my own semi-solution in the end.

I used SetX with -k switch to assign variables to values read from UserShellFolders. I even managed to then use those same variables back within the User Shell Folders key itself! (you just need to ensure that the variable is set early enough, so that when the reg key is read it knows what to expand). It's a bit kludgy, but it works reliably and does do what I wanted to achieve.

Ricktendo64's suggestion is much more elegant though, and would be my preferred method, provided that I can get it to work - (I'm still a noob).

Thanks again everyone.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...