We do quite some scripting and little helpers with batch files (
xyz.cmd) at work. Windows 7 is only now starting to become widespread here, and obviously, we hit the problems associated with the different environment variables of 32bit vs. 64bit windows.
Specifically, if you run
C:\Windows\system32\cmd.exe on a 64 bit Windows, you'll get:
... ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files ...
whereas, if you start
C:\Windows\SysWOW64\cmd.exe on a 64 bit Windows, you'll get:
... ProgramFiles=C:\Program Files (x86) <-- NOTE ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files ...
It also so happens, that because this cmd.exe is a 32bit process, it also gets all the other SysWOW64 redirections "for free" -- any invocation of
regedit will go to the 32bit registry, etc.
This can be extremely useful if the batch file is supposed to do some tasks related to a 32bit application, e.g. path + registry stuff.
GIven that I have a class of batch files that I would wish to always run with the 32bit version of
cmd.exe, is there an -- easy! -- way to force these batchfiles to always use the 32bit cmd.exe on 64bit versions of Windows and run normally on 32bit versions of Windows?
Obviously I can add a "header" to each such batch-file to change environment variables and regedit invocations and/or obviously I could just tell users to "run this batch file via the SysWOW64 cmd.exe", but neither of these solutions seems very attractive :-)