Windows Command Line – Set Environment Variable
The windows command line or text interface is a kind of user interface that can be controlled by passing commands in the form of prompts instead of using a mouse. Command-line is different from GUI OS, i.e., Graphical User Interface Operating System. It only needs a keyboard to control and navigate by passing the commands instead of a mouse.
For example, to open the windows folder in the windows command line, we use “C:\Windows”.
However, using the command line requires one to remember lots of commands. However, it is very useful which should not be ignored. Command-line allows a user to perform all the tasks that they can perform on a GUI OS. And sometimes, there are many tasks that we can accomplish even quicker than GUI OS, and they are very easy to automate as well.
For example, if a person is asked to rename 50 files in a folder at a time. So, setting an environment variable with GUI can be very time-consuming but with the help of the windows command line, this can be done in seconds by passing a single command using a batch file or other scripts.
What is an Environment Variable?
An environment variable is a dynamic object that contains an editable value. It can be used by more than one software program in windows. The role of environment variables is to let the programs know which file directories to install, the location of temporary files, and the user profile settings. These are named environment variables because they shape the environment of the essential programs to run a computer.
How to set environment variables?
To set up an environment variable, the running system should have windows 10 OS. The user account should have admin privilege. It should also have access to Command Prompt or Windows PowerShell. Users can set up environment variables in two ways –
1. Via GUI
To set up environment variable using GUI, the user should follow the following steps-
- With the help of windows run, open System Properties.
- Then select the Advanced option in the top menu and set Environment Variables.
- The Environment Variables have two sections, user-specific and system-wide. So, to add a new environment variable, press the new button. Then, the user can add the variable according to their choice.
2. Via Command Prompt
- To set an environment variable with the help of a command prompt, use ‘setx’.
- For example – setx [variable_name] “[variable_value]. Here, the variable name can be assigned the name of the variable you want to keep and value, the value you want to assign the variable.
- Furthermore, if a user wants to add a system-wide environment variable, then use – setx [variable_name] “[variable_value]” /M.
Other useful articles:
- Basic Windows CMD commands
- Cool CMD Commands Tips and Tricks
- Best CMD Commands for Hacking
- CMD Commands for Wireless Network Speed
- Useful Keyboard Shortcuts for CMD
- What Info about My Laptop Can I Check with CMD and How?
- Getting Started with CMD Windows
- TOP-12 Command-Line Interview Questions (Basic)
- Command-Line Interview Questions (Advanced)
- CMD Commands to Repair Windows
- CMD Commands to Speed Up Computer
- CMD Commands for MAC OS
- How Does the Command Line Work?
- MS-Dos Interview Questions in 2021
- Windows OS Versions and History
- Recent Windows Versions Compared
- Basic Windows Prompt Commands for Every Day
- Windows Command Line Cheat Sheet For Everyone
- Windows Command Line Restart
- Windows Command Line for Loop
- Windows Command - Change Directory
- Windows Command - Delete Directory
- Windows Command Line – Set Environment Variable