Command Not Recognized When Using System Exec VI

Updated Oct 13, 2023

Reported In

Software

  • LabVIEW Full
  • LabVIEW Base

Other

  • Windows 64-bit
  • LabVIEW 32-bit

Issue Details

I am trying to call a Windows executable found in the System32 folder with the System Exec VI. I get an error stating: 
'C:\Windows\System32\msg.exe' is not recognized as an internal or external command, operable program or batch file.


Figure 1. Error Message

Note: msg.exe may be replaced by another program you are trying to call or the path to your System32 folder may differ.

When I try this same command from a Command Prompt, it works just fine. I am using a 64-bit Windows operating system but 32-bit LabVIEW.  What am I doing wrong?

 

Solution

The problem is with the way Windows stores and directs calls to 32-bit system applications in 64-bit Windows. These 32-bit executables are actually contained in the Windows\Sysnative folder, not the Windows\System32 folder.

LabVIEW 32-bit runs on the WOW layer in a Windows 64-bit environment and can therefore only access the 32-bit namespace. When the System Exec VI calls cmd.exe, the cmd.exe called is native to the operating system, in this case a 64-bit version. This requires a switch in namespaces between the 64-bit and the 32-bit namespaces. Since the command is being called through a 32-bit LabVIEW application, Windows cannot properly link from the 32-bit application, through the 64-bit system command prompt, and back to the 32-bit executable.

To fix the problem, the input string for the System Exec VI needs to be changed to explicitly reference the Windows\Sysnative folder instead of the Windows\System32 folder.
 

If this is returning an error or not working:


Figure 2. Fails on 64-bit Windows (VI Snippet)

Use this instead:


Figure 3. Works on 64-bit Windows (VI Snippet)

Note: If you have this problem and try to call the command without the cmd /c in the input string, you will receive a LabVIEW Error 2: Memory is Full.