Shelling to run an OS command from Windows 64-Bit from UniVerse

UniVerse provides you the ability to run an OS command using the "!" or "sh" from TCL or using EXECUTE.

EXECUTE \!msg * "Test message popup"\

There are many process that use this feature to interact with the operating systems, but recently I ran across a problem. When you run UniVerse 32-bit Server on a Windows 64-Bit OS it works fine, except some command line tools are unavailable.

This is due to Windows WOW64 (Windows-On-Windows) subsystem. The Windows-On-Windows (WoW) subsystem has been included in Windows operating systems to allow for backwards compatibility. It has enabled the execution of 16-bit applications on modern 32-bit based Windows. This abstraction layer is located in user space translating API calls to 64-bit data structures and entry points. This is called API call thunking. Windows x64 Editions include a new variant of the WoW, called WoW64, subsystem thunking API calls for 32-bit applications on the 64-bit kernel.

WoW64 includes several mechanisms to separate file system and registry information for 32-bit applications from 64-bit applications in order to run unchanged on Windows x64. One of the tasks of WoW64 is file system redirection which makes 32-bit tools and libraries available in the expected location:

  • On Windows x64, the 32-bit version of %SystemRoot%\System32 (as found on 32-bit Windows) is relocated to %SystemRoot%\SysWoW64.
  • For 32-bit applications to work properly, WoW64 redirects every access to the new location.

As a very nasty consequence of this design, 32-bit applications are not able to call 64-bit tools located in the original %SystemRoot%\System32 because of the redirection. Fortunately, Microsoft has included most tools in both versions (32- and 64-bit). However, some useful tools are only available in 64-bit versions including shutdown.exe, logoff.exe, msg.exe, tsdiscon.exe and tsshutdn.exe.

In the articleJailed 32-Bit Processes on Windows x64 (Update) I found a solution that worked well.