为什么 Windows Vista 64 位默认使用 32 位 cmd.exe? (机器特定)

发布于 2024-07-10 01:48:56 字数 1248 浏览 9 评论 0原文

情况:

我需要将当前的开发环境从 Windows XP 32 位转换为 Windows Vista 64 位 (*)。 当然,我在构建系统中遇到了很多硬编码路径存在问题的地方(例如“C:\Program Files”变成了“C:\Program Files (x86)”代码>”)。 幸运的是,有一个 %ProgramFiles% 环境变量,它根据源进程(32 位或 64 位)映射到正确的目录。 所以我用 %ProgramFiles% 更新了构建脚本,我确信一切都会结束。

构建环境是从命令行 (C:\Windows\System32\cmd.exe) 调用的。

问题: 在一台特定的机器上(即我工作中的开发机器),事实证明 C:\Windows\System32\cmd.exe 实际上是一个 32 位进程,因此脚本找到 x86< /code> 版本的 Program Files 目录,一切正常。

在我能找到的所有其他 64 位计算机上(包括我的家用计算机),C:\Windows\System32\cmd.exe 是 64 位版本,32 位版本位于 C:\Windows \SysWow64\cmd.exe。 因此构建脚本无法找到他们正在寻找的任何内容并且失败。

我现在明白,如果您需要的话,应该显式调用 32 位 cmd.exe,默认情况下您会得到 64 位 cmd.exeWORKSFORME 的典型案例...

问题是,如果这不是真的,机器发生了什么? 为什么我在一台机器上默认获得 32 位 cmd.exe 而在其他机器上却没有? 在所有情况下,我都从 Start|Run 菜单显式执行 C:\Windows\System32\cmd.exe,但仅在一台计算机上获得不同的结果嗯>。 所有这些都运行相同版本的 Vista 64 位。

有什么想法或见解吗?

(*) 请接受我必须这样做。 我无权说出为什么我要这样做。 重新安装操作系统并从头开始一切可能会起作用,但这肯定是矫枉过正。 此外,说服我们的 IT 部门提供 Vista 机器已经够困难的了!

The situation:

I need to convert our current development environment from Windows XP 32-bit to Windows Vista 64-bit (*). Naturally, I've run into plenty of places in our build system where hardcoded paths were problematic (e.g. "C:\Program Files" becoming "C:\Program Files (x86)"). Fortunately, there is a %ProgramFiles% environment variable which maps to the proper directory based on the source process (32-bit or 64-bit). So I updated the build scripts with %ProgramFiles%, and I was sure it'd be the end of that.

The build environment is called from the command-line (C:\Windows\System32\cmd.exe).

The problem:
On one specific machine (namely my dev machine at work), it turns out that C:\Windows\System32\cmd.exe is actually a 32bit process, so the scripts find the x86 version of the Program Files directory and everything works great.

On every other 64bit machine I can find (including my home machine), C:\Windows\System32\cmd.exe is the 64bit version, and the 32bit version is in C:\Windows\SysWow64\cmd.exe. So the build scripts can't find anything they're looking for and fail.

I understand now that the 32bit cmd.exe should be called explicitly if that's what you need, and by default you get a 64bit cmd.exe. Typical case of WORKSFORME...

The question is, what happened to the machine where this is not true? Why am I getting a 32bit cmd.exe by default on one machine but not on others? In all cases I am explicitly executing C:\Windows\System32\cmd.exe from the Start|Run menu but getting different results on one machine only. All are running the same edition of Vista 64bit.

Any thoughts or insight?

(*) Please accept that I must do this. I am not at liberty to say why I am doing this. Re-installing the OS and everything from scratch would probably work, but it is surely overkill. Besides, it was hard enough convincing our IT department to give out Vista machines!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

走过海棠暮 2024-07-17 01:48:56

如果您从 32 位进程运行 cmd,则由于文件重定向 (http://msdn.microsoft.com/en-us/library/aa384187.aspx)。 当您从资源管理器运行 CMD 时,是否会获得 32 位版本的 CMD?

If you ran cmd from a 32-bit process, you'd get the 32-bit cmd because of File Redirection (http://msdn.microsoft.com/en-us/library/aa384187.aspx). Do you get the 32-bit version of CMD when you run it from Explorer?

无人问我粥可暖 2024-07-17 01:48:56

我终于找到了问题所在,正如预期的那样,问题很简单:用户错误。 Explorer(它本身是 Windows Vista 64 位上的 64 位进程)默认启动 64 位命令提示符。 如果您需要 32 位 CMD.EXE,则必须显式引用 C:\Windows\SysWoW64\CMD.EXE

这在我的系统上运行良好的原因是我使用 Far Manager 进行大部分命令行使用,它是 32 位的(因此它启动 32 位命令提示符)。 当我验证时,我一定是混淆了 32 位窗口和 64 位窗口(毕竟它们看起来一样!)并问了一个愚蠢的问题。

死了,%ProgramFiles(x86)% 的问题是它在 Windows Vista 32 位上不存在,因为那样确实更简单。

啊,没有什么比公开发帖更能让自己出丑的了……:)

I have finally found the problem, and as expected it is quite simple: user error. Explorer (which is itself a 64-bit process on Windows Vista 64-bit) launches 64-bit command prompts by default. If you want a 32-bit CMD.EXE, you must explicitly reference C:\Windows\SysWoW64\CMD.EXE.

The reason this worked fine on my system is that I use Far Manager for most of my command-line usage, which is 32-bit (therefore it launches 32-bit command prompts). When I verified I must have confused a 32-bit window for a 64-bit window (after all they look the same!) and asked a stupid question.

Die in Sente, the problem with %ProgramFiles(x86)% is that it doesn't exist on Windows Vista 32-bit, because that would have really been simpler.

Ah, there is nothing like a public posting to make a fool of yourself... :)

初懵 2024-07-17 01:48:56

cmd.exe 从两台计算机的“开始”菜单中启动。 准确重现:

  • 单击“启动球
  • ”,输入“cmd”,仅出现一个匹配项 (c:\windows\system32\cmd.exe)
  • 启动它。

在我的工作计算机上,它启动 32 位版本(如任务管理器所示,它已将 *32 附加到 Processes 选项卡中的名称)。 在我尝试过的所有其他 Vista 64 计算机上,这会启动 64 位版本的 cmd,并且我找不到此行为的合理解释。

我还没有检查 explorer.exe 本身在受影响的计算机上是 32 位还是 64 位,也许这是相关的......感谢您的提示。

cmd.exe is launched from within the Start menu on both machines. Exact repro:

  • Click the Start Orb
  • Type "cmd", only one match comes up (c:\windows\system32\cmd.exe)
  • Launch it.

On my work machine, it launches the 32bit version (as demonstrated by the Task Manager, it has *32 appended to the name in the Processes tab). On all other Vista 64 machines I've tried, this launches the 64bit version of cmd, and I cannot find a rational explanation for this behavior.

I haven't checked if explorer.exe itself was 32bit or 64bit on the affected machine, maybe this is related... Thanks for the hint.

花期渐远 2024-07-17 01:48:56

除了 %ProgramFiles% 之外,不是有一个 %Programfiles(x86)% 可以始终到达您想要的位置,无论哪个 cmd.exe 正在运行? 我的 Windows XP 64 位系统都有这个; 请原谅我没有花时间启动 Vista 系统。

Instead of %ProgramFiles%, isn't there a %Programfiles(x86)% that always goes where you want, regardless of which cmd.exe is running? My Windows XP 64-bit systems all have that; excuse me for not taking the time to boot up a Vista system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文