Abhay
Abhay

Reputation: 25

Why some variable need %variable% syntax to access its value while other don't in window cmd

for path

>echo %path%

>path

both works but

for os

>echo %os% works

>os gives error

Upvotes: 0

Views: 26

Answers (1)

Joe Inwap
Joe Inwap

Reputation: 171

That is because "path" is a command, defined in CMD.EXE. And "echo" is another command. But %os% is a variable, not a command. Basically commands are defined if they are useful. Having a separate command to output the OS version other than "echo" was not deemed necessary.

Upvotes: 1

Related Questions