Published on

How to create and manage Windows Environment Variables.

Authors
  • avatar
    Name
    how-to.digital
    Twitter

How to Create and Manage Windows Environment Variables

Environment variables are a crucial part of a Windows operating system as they contain information that programs and scripts utilize to function correctly. In this tutorial, we will explore how to create and manage environment variables on Windows.

Prerequisites

Before we start, make sure you have the following:

  • A Windows operating system (Windows 7 or later)
  • Administrator privileges on your user account

Step 1: Accessing System Properties

  1. Press Win + Pause/Break or right-click on the "Computer" or "This PC" icon on your desktop and select "Properties." This will open the System Properties window.

Step 2: Opening Environment Variables Configuration

  1. In the System Properties window, click on the "Advanced system settings" link on the left-hand side. This will open the System Properties dialog box.
  2. Under the "Advanced" tab, click on the "Environment Variables" button.

Step 3: Creating a New User-level Environment Variable

  1. In the Environment Variables dialog box, you will see two sections: User variables and System variables.
  2. To create a user-level environment variable, navigate to the "User variables" section and click on the "New" button.
  3. Enter the name and value for your new environment variable. The name should be in uppercase letters and without any spaces (e.g., MY_VARIABLE), and the value can be anything you need for your specific use case. Click "OK" to save the variable.

Step 4: Creating a New System-level Environment Variable

  1. To create a system-level environment variable, navigate to the "System variables" section in the Environment Variables dialog box and click on the "New" button.
  2. Enter the name and value for your new environment variable. Ensure the name is in uppercase letters and without any spaces.
  3. Click "OK" to save the variable.

Step 5: Modifying an Environment Variable

  1. In the Environment Variables dialog box, locate the variable you want to modify under either the "User variables" or "System variables" section.
  2. Select the variable and click on the "Edit" button.
  3. Update the value of the variable and click "OK" to save the changes.

Step 6: Deleting an Environment Variable

  1. If you wish to delete an environment variable, locate it under either the "User variables" or "System variables" section.
  2. Select the variable and click on the "Delete" button.
  3. Confirm the deletion by clicking "OK."

Step 7: Understanding Variable Scope

  • User-level variables are specific to the currently logged-in user and are accessible only to programs running under that user account.
  • System-level variables, on the other hand, are accessible to all users on the system and can be used by any program running on that machine.

Step 8: Using Environment Variables in Programs

To utilize environment variables within a program or script, reference them as %VARIABLE_NAME%. For example, if you have an environment variable named PATH, you can access it as %PATH%.

Congratulations! You have successfully learned how to create, modify, and manage Windows environment variables. These variables play a vital role in configuring your system and customizing your workflow.