Monday, September 17, 2012

Windows 64-bit uses MSHTA.EXE 32-bit

By default, Windows 2008 R2 uses the 32-bit version of MSHTA.EXE even if the parent process is 64-bit, such as double-clicking an HTA from the Explorer process. This is due to the htafile association pointing to the 32-bit version.


While it seems that this should be corrected by updating the registry with the 64-bit path, there are sites on the Internet the state this might not be a good idea; though no reason was given. A quick guess is that the server-based HTA's used for server configuration may break.

An issue that was encountered due to this configuration is the calling of 32-bit programs when only the 64-bit version actually works.

For example, calling the NBTSTAT.EXE command from a 32-bit Command Prompt will result in the following error:


'nbtstat' is not recognized as an internal or external command, operable program or batch file.

The same error is encountered when using WScript.Shell.Exec to call NBTSTAT.EXE from a 32-bit MSHTA.EXE on a 64-bit operating system.

As a workaround, call the 64-bit/32-bit version directly by using a CMD or BAT file that uses a similar command (this command will call the 32-bit version on a 32-bit OS and the 64-bit version on a 64-bit OS):

START %windir%\system32\mshta.exe "<PathToHTA>"