likejudo
likejudo

Reputation: 3735

How to access environment variable from command prompt?

On Windows 7, I created a system environment variable. Surprised to find that I cannot access its value.

JETTY_HOME=D:\workspace\jetty-distribution-9.4.8.v20171121

C:\Users\me>cd %JETTY_HOME%

C:\Users\me>set

....
JETTY_HOME=D:\workspace\jetty-distribution-9.4.8.v20171121
....

C:\Users\me>cd JETTY_HOME
The system cannot find the path specified.

Upvotes: 1

Views: 269

Answers (1)

Sami Sallinen
Sami Sallinen

Reputation: 3494

The plain cd command does not change the current drive from c: to d:. The /d switch tells the command to also change the drive. So:

CD /D %JETTY_HOME%

Works from any drive.

Upvotes: 3

Related Questions