What happens when I use the environment variable %PROGRAMFILES(x86)%
on a Windows OS that is 32bit (ie, older versions of Windows such as Windows XP, Vista)?
当我在Windows操作系统上使用环境变量%PROGRAMFILES(x86)%时,会发生什么情况?
I am hoping that it will simply resolve to: C:/Program Files
. Will this occur?
我希望它能简单地解析为:C:/程序文件。这会发生吗?
3 个解决方案
#1
36
According to this the environment variable %PROGRAMFILES(x86)%
is only available on 64-bit systems.
根据此,环境变量%PROGRAMFILES(x86)%只能在64位系统上使用。
However, if you are on a 64-bit system and use %PROGRAMFILES%
, the result you get depend on whether the process requesting the environment variable is 32-bit or 64-bit.
但是,如果您在64位系统上使用%PROGRAMFILES%,那么您得到的结果取决于请求环境变量的进程是32位还是64位。
So from a 64-bit process on a 64-bit system you would get C:\Program Files
, from a 32-bit process on a 64-bit system you would get C:\Program Files (x86)
, and from a 32-bit process on a 32-bit system you would get C:\Program Files
.
所以从一个64位的过程在64位系统上你会得到C:\程序文件,从一个32位进程在64位系统上你会得到C:\Program Files(x86),和一个32位的过程在32位系统上你会得到C:\程序文件。
If this doesn't help, perhaps you can comment or edit your original question to make it specific what you are trying to do. As it currently stands, the answer to your question is "No".
如果这没有帮助,也许你可以评论或编辑你的原始问题,使它具体化你想做的事情。就目前而言,你的问题的答案是“不”。
#2
2
Keith Hill answered this question here, summary:
Keith Hill在这里回答了这个问题,总结:
${env:ProgramFiles(x86)}
is not defined on a 32-bit machine${env:ProgramFiles(x86)}不是在32位机器上定义的。
If you always want to put/get data to/from x86 directory, then you can use this code to determine file paths:
如果您总是希望将数据放在x86目录中,那么您可以使用此代码来确定文件路径:
$file = "\file"
if ("${Env:ProgramFiles(x86)}")
{
$fullPath = "${Env:ProgramFiles(x86)}\$file"
}
else
{
$fullPath = "${Env:ProgramFiles}\$file"
}
#3
-13
If you use %programfiles%
on a 32-bit computer/laptop it will open C:\Program Files
.
如果你在32位的电脑/笔记本电脑上使用%programfiles%,它将打开C:\程序文件。
If you use %programfiles%
on a 64-bit computer/laptop it will open C:\Program Files
.
如果你在64位电脑/笔记本电脑上使用%programfiles%,它将打开C:\程序文件。
If you have a 64-bit program installed on a 32-bit computer/laptop, it will be installed in a new folder named Program Files (x64)
, which is located in the "C" drive. In which case you have to use %programfiles(x64)
.
如果您的64位程序安装在32位的计算机/笔记本上,它将安装在名为program Files (x64)的新文件夹中,该文件夹位于“C”驱动器中。在这种情况下,您必须使用%programfiles(x64)。
If you have a 32-bit program installed on a 64-bit computer/laptop, it will be installed in a new folder named Program Files (x86)
, which is located in the "C" drive. In which case you have to use %programfiles(x86)
.
如果您在64位计算机/笔记本上安装了一个32位程序,那么它将安装在一个名为program Files (x86)的新文件夹中,该文件夹位于“C”驱动器中。在这种情况下,您必须使用%programfiles(x86)。
#1
36
According to this the environment variable %PROGRAMFILES(x86)%
is only available on 64-bit systems.
根据此,环境变量%PROGRAMFILES(x86)%只能在64位系统上使用。
However, if you are on a 64-bit system and use %PROGRAMFILES%
, the result you get depend on whether the process requesting the environment variable is 32-bit or 64-bit.
但是,如果您在64位系统上使用%PROGRAMFILES%,那么您得到的结果取决于请求环境变量的进程是32位还是64位。
So from a 64-bit process on a 64-bit system you would get C:\Program Files
, from a 32-bit process on a 64-bit system you would get C:\Program Files (x86)
, and from a 32-bit process on a 32-bit system you would get C:\Program Files
.
所以从一个64位的过程在64位系统上你会得到C:\程序文件,从一个32位进程在64位系统上你会得到C:\Program Files(x86),和一个32位的过程在32位系统上你会得到C:\程序文件。
If this doesn't help, perhaps you can comment or edit your original question to make it specific what you are trying to do. As it currently stands, the answer to your question is "No".
如果这没有帮助,也许你可以评论或编辑你的原始问题,使它具体化你想做的事情。就目前而言,你的问题的答案是“不”。
#2
2
Keith Hill answered this question here, summary:
Keith Hill在这里回答了这个问题,总结:
${env:ProgramFiles(x86)}
is not defined on a 32-bit machine${env:ProgramFiles(x86)}不是在32位机器上定义的。
If you always want to put/get data to/from x86 directory, then you can use this code to determine file paths:
如果您总是希望将数据放在x86目录中,那么您可以使用此代码来确定文件路径:
$file = "\file"
if ("${Env:ProgramFiles(x86)}")
{
$fullPath = "${Env:ProgramFiles(x86)}\$file"
}
else
{
$fullPath = "${Env:ProgramFiles}\$file"
}
#3
-13
If you use %programfiles%
on a 32-bit computer/laptop it will open C:\Program Files
.
如果你在32位的电脑/笔记本电脑上使用%programfiles%,它将打开C:\程序文件。
If you use %programfiles%
on a 64-bit computer/laptop it will open C:\Program Files
.
如果你在64位电脑/笔记本电脑上使用%programfiles%,它将打开C:\程序文件。
If you have a 64-bit program installed on a 32-bit computer/laptop, it will be installed in a new folder named Program Files (x64)
, which is located in the "C" drive. In which case you have to use %programfiles(x64)
.
如果您的64位程序安装在32位的计算机/笔记本上,它将安装在名为program Files (x64)的新文件夹中,该文件夹位于“C”驱动器中。在这种情况下,您必须使用%programfiles(x64)。
If you have a 32-bit program installed on a 64-bit computer/laptop, it will be installed in a new folder named Program Files (x86)
, which is located in the "C" drive. In which case you have to use %programfiles(x86)
.
如果您在64位计算机/笔记本上安装了一个32位程序,那么它将安装在一个名为program Files (x86)的新文件夹中,该文件夹位于“C”驱动器中。在这种情况下,您必须使用%programfiles(x86)。