Environment variables are special variables that contain its values set by the operating system itself, other applications or by manual. Environment variables are set to reduce tasks and code complexity by calling them in program, since they are just placeholders that keeps track of the system properties and system wide changes, and then sets its value. It holds values like drive path, currently logged in username, root drive, Operating System name and version and so on.
The following are the few environment variables set in Windows XP:
S.No | Environment Variables | Description |
---|---|---|
1 | %ALLUSERSPROFILE% | C:\Documents and Settings\All Users |
2 | %APPDATA% | C:\Documents and Settings\{username}\Application Data |
3 | %CD% | Current working directory |
4 | %CMDCMDLINE% | Displays Windows Version |
5 | %CMDEXTVERSION% | Command prompt version |
6 | %COMPUTERNAME% | Equivalent to hostname command |
7 | %COMSPEC% | C:\Windows\System32\cmd.exe |
8 | %DATE% | Display current date |
9 | %ERRORLEVEL% | Exit code for the previously executed command |
10 | %HOMEDRIVE% | Root Drive |
11 | %HOMEPATH% | \Documents and Settings\{username} |
12 | %NUMBER_OF_PROCESSORS% | Displays number of processors |
13 | %OS% | Displays the name of the OS installed |
14 | %PATH% | Points to C:\WINDOWS\system32 |
15 | %PATHEXT% | .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH |
16 | %PROCESSOR_ARCHITECTURE% | Displays the processor architecture |
17 | %PROCESSOR_LEVEL% | Displays the processor level |
18 | %PROCESSOR_REVISION% | Displays the processor revision |
19 | %PROMPT% | Displays the current prompt |
20 | %RANDOM% | Generates a random integer between 0 and 32767 |
21 | %SYSTEMDRIVE% | Moves to the Root drive |
22 | %SYSTEMROOT% | C:\WINDOWS |
23 | %TEMP% and %TMP% | C:\DOCUME~1\{USER}\LOCALS~1\Temp |
24 | %TIME% | Displays current time |
25 | %USERDOMAIN% | Displays the hostname |
26 | %USERNAME% | Displays the currently logged in user name |
27 | %USERPROFILE% | C:\Documents |
28 | %WINDIR% | C:\WINDOWS |
You can manually set an environment variable using the “SET” command and those variables set by this command will not reside permanently in the system but they were temporary and will be lost after a reboot.
To set an environment variable manually by using ‘set’ command,
C:\>set C=C:\windows\system32\cmd.exe
C:\>%C%
In the above example, We have set an environment variable name ‘C‘ and assigned the value the path to the command prompt. Then value can be accessed by using % on both sides of the variable like ‘%c%‘. Since I have set the path to the command prompt to the variable ‘c‘, when the variable is accessed, it will open up a new command prompt in the existing window.
You may also like:- Top 20 Cybersecurity Career Options
- Top 5 Tips to Prevent Online Scams
- Top 10 Platforms to Learn Cybersecurity
- Top 7 Commercial Linux Distributions
- Why Do I Need a Website?
- Reinforcement Learning in Real-world Applications: The Latest Successes and Challenges
- Various Python Libraries for developing RESTful APIs
- Top 7 NodeJS Frameworks You Need To Know
- How Buying Instagram Followers Can Help Businesses Soar
- How To Find Gaps In Your Cybersecurity And How To Address Them