how to get program files x86 env variable?

前端 未结 4 1024
粉色の甜心
粉色の甜心 2020-11-29 21:13

I would like to know how I can display the location of Program Files (x86) in command prompt. I\'m using Windows 7 64bit.

I\'ve tried:

echo %programf

相关标签:
4条回答
  • 2020-11-29 21:47

    IMHO, one point that is missing in this discussion is that whatever variable you use, it is guaranteed to always point at the appropriate folder. This becomes critical in the rare cases where Windows is installed on a drive other than C:\

    0 讨论(0)
  • 2020-11-29 21:53

    Another relevant environment variable is:

    %ProgramW6432%

    So, on a 64-bit machine running in 32-bit (WOW64) mode:

    • echo %programfiles% ==> C:\Program Files (x86)
    • echo %programfiles(x86)% ==> C:\Program Files (x86)
    • echo %ProgramW6432% ==> C:\Program Files

    From Wikipedia:

    The %ProgramFiles% variable points to the Program Files directory, which stores all the installed programs of Windows and others. The default on English-language systems is "C:\Program Files". In 64-bit editions of Windows (XP, 2003, Vista), there are also %ProgramFiles(x86)%, which defaults to "C:\Program Files (x86)", and %ProgramW6432%, which defaults to "C:\Program Files". The %ProgramFiles% itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by Windows-on-Windows 64-bit redirection).

    Reference: http://en.wikipedia.org/wiki/Environment_variable

    0 讨论(0)
  • 2020-11-29 21:55

    On a 64-bit machine running in 64-bit mode:

    • echo %programfiles% ==> C:\Program Files
    • echo %programfiles(x86)% ==> C:\Program Files (x86)

    On a 64-bit machine running in 32-bit (WOW64) mode:

    • echo %programfiles% ==> C:\Program Files (x86)
    • echo %programfiles(x86)% ==> C:\Program Files (x86)

    On a 32-bit machine running in 32-bit mode:

    • echo %programfiles% ==> C:\Program Files
    • echo %programfiles(x86)% ==> %programfiles(x86)%
    0 讨论(0)
  • 2020-11-29 22:11

    On a Windows 64 bit machine, echo %programfiles(x86)% does print C:\Program Files (x86)

    0 讨论(0)
提交回复
热议问题