Monday, 8 September 2025

Environment Variables in Windows 11

To see your environment variables, type set in the command line. This will show you a bunch of stuff like:

ALLUSERSPROFILE=C:\ProgramData
ALLDATA=C:\Users\windowsjoe\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
COMPUTERNAME=windowsjoemachine
...
OS=Windows_NT (Even if you are using Windows 11)
...
USERDOMAIN=windowsjoemachine
USERDOMAIN_ROAMINGPROFILE=windowsjoemachine
USERNAME=windowsjoe
WINDIR=C:\Windows
..

And so on, and so forth.

The setx command is an extension of set which allows you to create or modify environment variables, persisting the result across sessions.  It was first integrated into Windows Vista and is a staple for Windows 10 and Windows 11. 

To use setx to append to your PATH variable you will want to do something like this:

setx PATH "%PATH%;C:\Your\New\Directory"

For Windows Joe, a special scripts directory holds a lot of useful scripts. Hence, the path is updated to:

setx PATH "%PATH%;C:\users\windowsjoe\scripts"

If successful, you will see the message "SUCCESS: Specified value was saved.".

However, you will not be able to see the results using echo %PATH% until you start a new session.

No comments: