views:

2441

answers:

4

(I have this weird configuration problem at work, so I thought I'd give this site a try. My Google-Fu is failing me...)

The situation: I need to convert our current development environment from XP 32bit to Vista 64bit (*). 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 (32bit or 64bit). 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?

Thanks!

(*) 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 is surely overkill. Besides, it was hard enough convincing our IT dept to give out Vista machines!

+1  A: 

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?

Paul Betts
+1  A: 

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.

Benoit Miller
After verification, the explorer.exe process is 64bit on all machines. I don't understand how a 64bit process defaults to launching the 32bit version of cmd... :(
Benoit Miller
A: 

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

Die in Sente
A: 

I have finally found the problem, and as expected it is quite simple: user error. Explorer (which is itself a 64bit process on Vista64) launches 64bit command prompts by default. If you want a 32bit CMD.EXE, you much 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 32bit (therefore it launches 32bit Command Prompts). When I verified I must have confused a 32bit window for a 64bit 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 Vista32, because that would have really been simpler.

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

Benoit Miller