Variables used by the windows OS.
Scopes
They can be defined in the scopes:
- User
- System
- Process (which are volatile and considered a sub-scope of the above)
Management
-
echo: Show variable -
set: Change/define a variable in current CMD sessions. -
setx: Change/define a variable permanently in registry (i.e. exists upon CMD restarts)Environment variables are removed by being set to an empty string
"".
Important Environment Variables
| Variable Name | Description |
|---|---|
| %PATH% | Specifies a set of directories(locations) where |
| executable programs are located. | |
| %OS% | The current operating system on the user’s |
| workstation. | |
| %SYSTEMROOT% | Expands to C:\Windows. A system-defined read-only |
| variable containing the Windows system folder. | |
| Anything Windows considers important to its core | |
| functionality is found here, including important | |
| data, core system binaries, and configuration | |
| files. | |
| %LOGONSERVER% | Provides us with the login server for the |
| currently active user followed by the machine’s | |
| hostname. We can use this information to know if | |
| a machine is joined to a domain or workgroup. | |
| %USERPROFILE% | Provides us with the location of the currently |
| active user’s home directory. Expands to | |
| C:\Users\{username}. | |
| %ProgramFiles% | Equivalent of C:\Program Files. This location is |
| where all the programs are installed on an x64 | |
| based system. | |
| %ProgramFiles(x86)% | Equivalent of C:\Program Files (x86). This |
| location is where all 32-bit programs running | |
| under WOW64 are installed. Note that this | |
| variable is only accessible on a 64-bit host. It | |
| can be used to indicate what kind of host we are | |
| interacting with. (x86 vs. x64 architecture) |