21.1. Environment Variables Overview

Environment variables are strings that contain information about a Windows system and/or about the configuration for the currently logged on user. This can affect how the operating system or individual processes behave. When Windows is being installed it configures environment variables, for example the path to the Windows files is contained in the windir environment variable. To see the value for the windir variable in Windows PowerShell, use the following command:

get-childitem var:windir

Alternatively, you can access the windir environment variable using this command:

$env:windir

As you can see in Figure 21-1, the value for the windir environment variable on my machine is C:\Windows.

Figure 21.1. Figure 21-1

To modify system environment variables, you must have administrator privileges. In addition to system environment variables such as windir, individual applications may create their own environment variables or users may specify environment variables.

To access information about environment variables using the Windows graphical user interface, select StartMy Computer then right-click and select Properties. On the System Properties dialog box, select the Advanced tab, which is shown in Figure 21-2.

Figure 21.2. Figure 21-2

On the Advanced ...

Get Professional Windows® PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.