How to get access to environment variables in Windows?
Solution 1
I'm not sure about whether your rights will allow it but you can try setting the path for a command window with path = %PATH%;newdir
; if it works, it will last until the command window is closed. This may be ok for you if you are mostly working at the command line.
There is also the setx tool that you could try if your rights allow you to install it.
Here is some additional information about the environment variables that may prove useful.
Solution 2
Yes, you can create your own environment.
- GUI:
- System Properties -> Advanced -> Environment Variables
- Or, if you don't have access this way, you might be able to get it by running
rundll32 sysdm.cpl,EditEnvironmentVariables
from the Run window or commandline.
- Or, if you don't have access this way, you might be able to get it by running
- Click Add, enter
PATH
as name and%PATH%;mynewdir
as value. (You don't need to include%PATH%
via the GUI, especially if you are editing an existingPATH
variable; it just holds the string value ofPATH
before you made edits.) - This is the only method that ensures instant availability to all future processes launched by Explorer, without the need to re-login.
- System Properties -> Advanced -> Environment Variables
- Kinda GUI:
-
regedit
->HKEY_CURRENT_USER\Environment
- Right-click, New -> Expandable String Value
-
- CLI:
reg add hkcu\environment /v PATH /t reg_expand_sz /d %%PATH%%;mynewdir
- Doubled
%%
is required to prevent%%PATH%%
from being expanded by shell.
Related videos on Youtube
Comments
-
Jonas over 1 year
I have borrowed a laptop with Windows XP from a company that I will do a project for. They say that I have almost Admiinistrator rights on the computer so that I can install software.
Now I have installed a few development tools, but I need to add a few things to the PATH environment variable. But I don't seem to have permissions to edit the PATH environment variable. Is there any way I could workaround this? Could I create a personal environment variable PATH that is used instead?
-
Pat almost 11 yearsAlso see serverfault.com/questions/33681/…
-
-
Jonas over 13 yearsI tried this and tested
setx
but I got this message:Access is denied
. I don't think it's possible to fix this. I have to contact the company. Thanks anyway. -
user1686 over 13 yearsThe correct syntax in
cmd
shell isset path=%path%;newdir
- note theset
prefix and no whitespace around=
-
Neal over 13 years@grawity The
set
is deliberately missing. Jonas explained in the question that he wasn't allowed to useset
to set the path. I wasn't sure where the block came in so I was pointing out a way to change the path for the current command window, with the hope that this might not be prevented by the lack of admin rights. I didn't bother listing the standard methods of changing the path because I read the question which told me they didn't work. -
user1686 over 13 yearsThe question does not mention
set
anywhere. There's more than one way of editing environment; maybe Jonas was talking about the GUI. (Besides, it is not possible to disable theset
builtin except by patchingcmd.exe
, and even then there are many ways to get around it.)