windows 如何获取程序文件 x86 环境变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9594066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get program files x86 env variable?
提问by Ashok
I would like to know how I can display the location of Program Files (x86) in command prompt. I'm using Windows 7 64bit.
我想知道如何在命令提示符中显示 Program Files (x86) 的位置。我正在使用 Windows 7 64 位。
I've tried:
我试过了:
echo %programfiles(x86)%
and echo %programfiles%
,
both of which displays only C:\Program Files
echo %programfiles(x86)%
和echo %programfiles%
,
两者都只显示C:\Program Files
When I manually checked the registry,
HKLM/Software/microsoft/windows/currentversion,
the programfilesdir
points to C:\Program Files
and
当我手工检查注册表,
HKLM /软件/微软/窗/ CURRENTVERSION,
该programfilesdir
点C:\Program Files
与
HKLM/Software/WOW64/Microsoft/winodws/currentversion,
the programfilesdir
points to C:\Program Files (x86)
.
HKLM /软件/ WOW64 /微软/的Winodws / CURRENTVERSION,
该programfilesdir
点C:\Program Files (x86)
。
But, why am I always being displayed with C:\Program Files??
但是,为什么我总是用 C:\Program Files 显示??
回答by SecurityMatt
On a 64-bit machine running in 64-bit mode:
在以 64 位模式运行的 64 位机器上:
echo %programfiles%
==>C:\Program Files
echo %programfiles(x86)%
==>C:\Program Files (x86)
echo %programfiles%
==>C:\Program Files
echo %programfiles(x86)%
==>C:\Program Files (x86)
On a 64-bit machine running in 32-bit (WOW64) mode:
在以 32 位 (WOW64) 模式运行的 64 位机器上:
echo %programfiles%
==>C:\Program Files (x86)
echo %programfiles(x86)%
==>C:\Program Files (x86)
echo %programfiles%
==>C:\Program Files (x86)
echo %programfiles(x86)%
==>C:\Program Files (x86)
On a 32-bit machine running in 32-bit mode:
在以 32 位模式运行的 32 位机器上:
echo %programfiles%
==>C:\Program Files
echo %programfiles(x86)%
==>%programfiles(x86)%
echo %programfiles%
==>C:\Program Files
echo %programfiles(x86)%
==>%programfiles(x86)%
回答by Vini
Another relevant environment variable is:
另一个相关的环境变量是:
%ProgramW6432%
%程序W6432%
So, on a 64-bit machine running in 32-bit (WOW64) mode:
因此,在以 32 位 (WOW64) 模式运行的 64 位机器上:
- echo %programfiles% ==> C:\Program Files (x86)
- echo %programfiles(x86)% ==> C:\Program Files (x86)
- echo %ProgramW6432% ==> C:\Program Files
- echo %programfiles% ==> C:\Program Files (x86)
- echo %programfiles(x86)% ==> C:\Program Files (x86)
- 回声 %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).
%ProgramFiles% 变量指向 Program Files 目录,该目录存储所有已安装的 Windows 程序和其他程序。英语语言系统上的默认值是“C:\Program Files”。在 64 位版本的 Windows(XP、2003、Vista)中,还有 %ProgramFiles(x86)%,默认为“C:\Program Files (x86)”和 %ProgramW6432%,默认为“C: \程序文件”。%ProgramFiles% 本身取决于请求环境变量的进程本身是 32 位还是 64 位(这是由 Windows-on-Windows 64 位重定向引起的)。
Reference: http://en.wikipedia.org/wiki/Environment_variable
回答by Sriranga Chidambara
On a Windows 64 bit machine, echo %programfiles(x86)% does print C:\Program Files (x86)
在 Windows 64 位机器上, echo %programfiles(x86)% 确实打印 C:\Program Files (x86)
回答by Amir Katz
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:\
恕我直言,本次讨论中缺少的一点是,无论您使用什么变量,都保证始终指向适当的文件夹。在 Windows 安装在 C:\ 以外的驱动器上的极少数情况下,这变得至关重要