Jump to content

Set permanent environment variable


T D

Recommended Posts


Hi,

Environmental Variables are stored in the Registry.

Current User:

HKCU\Environment

Local Machine:

HKLM\System\CurrentControlSet\Control\Session Manager\Environment

Use a tool like reg.exe to modify these.

Bye, Egon

Link to comment
Share on other sites

Is there anyway to set a permanent environment variable via a batch file? set *=* only works during the batch.

REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Enviroment" /v "EnviromentVariableName" /d "EnviromentVariableValue"

Link to comment
Share on other sites

You can set it by simply going to control panel - system - advanced & selecting the environmental variable at the bottom. You can add, edit or delte required settings here. I always change this to set my temp file to an independent 5 gb partition created for this purpose. Keeps your c: drive neat & clean. You can also set user specific environment here. No need to tinker with the registry.

Link to comment
Share on other sites

You can set it by simply going to control panel - system - advanced & selecting the environmental variable at the bottom. You can add, edit or delte required settings here. I always change this to set my temp file to an independent 5 gb partition created for this purpose. Keeps your c: drive neat & clean. You can also set user specific environment here. No need to tinker with the registry.

Hi PMshah,

the OP wanted to know if global environment variable setup is possible from within BATCH FILES, not manually.

Bye, Egon

Link to comment
Share on other sites

Thanks egrath for clarification.

pmshah thanks too but I wanted to know if I could automate this.

REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Enviroment" /v "EnviromentVariableName" /d "EnviromentVariableValue"

Thanks Belazel, that's what I needed.

Link to comment
Share on other sites

I have a similar question: how do I incorporate a variable in a reg add command.

For example, if I define %media% as my media drive, which is G:, how can I use that variable to change the icon of that drive using that variable instead of G.

The regkey I want to modify is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\G

Link to comment
Share on other sites

spacesurfer :

@echo off
set media=G
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%media%" /ve /d "X:\Path\To\Your\Icon.ico" /f

I'm interested with that too 'coz i never see it working when set manually with regedit (icon cache rebuilt) ????

++

Link to comment
Share on other sites

  • 4 weeks later...

Delprat,

Finally got around to making this work.

Upon a fresh install, I used the FOR command in a script to search my partitions for files called programs.tag, media.tag, images.tag, documents.tag and apply icons called programs.ico, media.ico, documents.ico and images.ico.

It works perfectly. No need to rebuild cache. Hitting F5 to refresh updates the icons for those partitions.

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...