64bit DOS commands with a 32bit (two-bit) application

This week I worked with a group of people that have a monitoring application — basically a glorified task scheduler for 32bit DOS applications. Among other things, this application attempts to check Microsoft Cluster Services (MSCS) failover status and send emails (using BLAT.exe) in the event a cluster was unbalanced. The code was no longer working after moving to Windows 2008R2. While helping them debug code, I realized that the ‘cluster’ command was not producing any output; likely due to the 32bit mode scheduler. A quick Google search came up with a simple solution — use the Windows SYSNATIVE directory instead of SYSTEM32 (http://www.tipandtrick.net/2008/how-to-suppress-and-bypass-system32-file-system-redirect-to-syswow64-folder-with-sysnative/).

However, updating the code caused a slight problem because the sysnative path was not available on their down level clusters. Here is a very simple workaround, but one I thought worth mentioning:

if exist "C:\Windows\sysnative\cluster.exe" (
set clusterPath="C:\Windows\sysnative\cluster.exe"
) else (
set clusterPath=%windir%\system32\cluster.exe
)

echo %clusterPath%

This batch file code checks for the existence of the sysnative\cluster.exe and if it is not available fails back to the previous path. A very simple solution, but the customer is happy.

This entry was posted in Scripting. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.