windows - 为什么 cmd.exe 和 PowerShell 中 ProgramFiles 变量的值不同?

标签 windows powershell environment-variables windows-7-x64

我在 64 位 PC 上使用 Windows 7 Professional SP1。如果我打开 PowerShell 控制台并查看 $env:ProgramFiles,其值为“C:\Program Files (x86)”。但是,如果我打开 cmd.exe 并查看 %ProgramFiles%,其值为“C:\Program Files”。

有人可以解释一下为什么它们不同吗?我本以为它们要么是相同的,要么 cmd.exe 认为它生活在 32 位环境中。

最佳答案

您已打开 32 位 Power Shell:Windows Power Shell (x86)

变量的值取决于调用进程的位数。 如果您打开 32 位 CMD.EXE,(%windir%\SysWoW64\cmd.exe),%ProgramFiles% 也将指向 x86 文件夹。

关于windows - 为什么 cmd.exe 和 PowerShell 中 ProgramFiles 变量的值不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59452724/

相关文章:

windows - 如何将 WinRT 异步任务集成到现有的同步库中?

windows - 为什么调用 ProcessGroupPolicyEx 回调会导致访问冲突?

windows - 通过服务名称获取 Windows 服务的 PID

powershell - 在 PowerShell 中区分不同类型的哈希表?

windows - 如何在 PATH 中包含 %ProgramFiles%?

python - 如何设置 Airflow 使用的环境变量?

linux - 在 Linux 上动态设置环境变量

linux - 使用rust : error cross-compilation from Linux to Windows i686

Azure CLI key 保管库恢复显示错误消息 - 是否有重试策略?

正则表达式 - 非捕获组不起作用