我在 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/