Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Environment variables are essential components in the Windows operating system that store configuration values. These variables can influence the behavior of running processes and applications. In this article, we will explore how to create, modify, and manage environment variables using both the graphical user interface (GUI) and command-line tools like Command Prompt (CMD) and PowerShell.
Environment variables are key-value pairs that can be used to configure the operating system and applications. Common environment variables include PATH
, TEMP
, and USERPROFILE
.
Open System Properties:
Add or Edit Environment Variables:
Example: Adding a New Variable:
MY_CUSTOM_VAR
.C:\MyCustomPath
.View Environment Variables:
cmd
in the search bar and hitting Enter.set
and press Enter to display all environment variables.Set a New Environment Variable:
set
command:
set MY_CUSTOM_VAR=C:\MyCustomPath
setx
command:
setx MY_CUSTOM_VAR "C:\MyCustomPath"
Example: Adding a Path to the PATH Variable:
PATH
environment variable for the current session:
set PATH=%PATH%;C:\NewPath
setx PATH "%PATH%;C:\NewPath"
View Environment Variables:
powershell
in the search bar and hitting Enter.Get-ChildItem
cmdlet to list all environment variables:
Get-ChildItem Env:
Set a New Environment Variable:
$env:MY_CUSTOM_VAR = "C:\MyCustomPath"
Example: Adding a Path to the PATH Variable:
PATH
environment variable for the current session:
$env:PATH += ";C:\NewPath"
$currentPath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
$newPath = $currentPath + ";C:\NewPath"
[System.Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
Managing environment variables in Windows is a fundamental skill for any systems engineer. Whether you prefer using the GUI, CMD, or PowerShell, Windows provides multiple ways to set and manage these critical settings.