LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System Exec VI not generating Standard output or File

Solved!
Go to solution

Hi,

 

I have seen many threads regarding getting the hardware information as in device manager, most of which suggest playing around with devmgr.dll, ActiveX device manager container and devcon utility. How ever I am trying to using Pnputil which is a command-line utility native to windows.

 

Problem:

When I use pnputil via cmd I get proper out and if need it also directs the standard output to a file.

When try to do the same using System Exec VI in Labview it does not generate standard error and even if I try to direct it to a file the file does not get created.

 

I am using the following command which works perfectly fine in cmd.

linu95k_1-1652853272850.png

 

However on running it from Labview System exec the standard output is blank and so is the file.

 

Can anyone please help resolve this?

 

Regards,

Linus Koli

 

 

 

0 Kudos
Message 1 of 14
(2,709 Views)

Hey!

I had the same issues with the SystemExec from LabVIEW in the past and switched to the JKI .NET System Exec

 

Since then I had zero trouble with it, so give it a try.

0 Kudos
Message 2 of 14
(2,698 Views)

Did you set the "wait for completion input (T)?" to True?

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 14
(2,679 Views)

I had the same Idea and even I tried JKI dot net exec but still I am facing the same issue.

0 Kudos
Message 4 of 14
(2,675 Views)

Yes, I have. However I am getting the error stating that pnputil is not an operable command. Where as it works in cmd.

0 Kudos
Message 5 of 14
(2,672 Views)

Then try to prepend "cmd /c" in the string before the pnputil command. LabVIEW System Exec is NOT a command shell interpreter, just a process launcher. cmd.exe is the program that presents you that nice black command line window but it doesn't just run external commands in the form of processes, but also contains a scripting interpreter, batch file execution and has a few other tricks up its sleeves that LabVIEW neither wants nor could replicate.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 14
(2,663 Views)

I have done that already... can anyone try executing it at their end?

I get the error pnputil is not an operable command but it works on cmd so not sure what the problem is here.

I am passing the following command to the command line input of System Exec.

 

cmd /c pnputil /enum-devices /connected

 

And using the same command without cmd /c command cmd.

 

 

 

0 Kudos
Message 7 of 14
(2,655 Views)

I tried with cmd /c start c:\temp\pnpu.cmd, where pnpu.cmd is a command file that works interactively.

A console window appears stating that pnputil is not recognized etc...

Then, from this window I change dir to c:\windows\system32 and search (dir command) for pnputil. But it's not found.

In this environment, c:\windows\system32 contains 3051 files. In a "normal" console window, it contains 4613 files.

 

 

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 8 of 14
(2,650 Views)

Ahhhh, you are using 32 bit LabVIEW but pnputil only exists as 64-bit executable.And Microsoft in its infinite wisdom decided that a 32-bit application only has access to 32-bit executables.

It won't even help to explicitly invoke the full path "C:\Windows\System32\pnputil.exe" as Windows will very "helpfully" translate that path to "C:\Windows\SysWOW64\pnputil.exe" before trying to interpret it.

 

There is a way to disable path redirection temporarily in a 32-bit process by calling a Windows API but it is wrought with trouble.

 

https://docs.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-wow64disablewow64fsred...

 

This API works thread specific (to minimise the potentially dangerous effects it could have in a process as the redirection will be disabled for any and all path operations in the active thread and if that was process global, other threads could totally and fatally fail such as when trying to load DLLs).

 

Only in LabVIEW it is kind of hard to guarantee that multiple calls are all done in the same thread so your Wow64DisableWow64FsRedirection() call might be executed in a different thread than your Wow64EnableWow64FsRedirection() call and that could be again in a different thread than our SystemExec() call. It might work if you execute them all in the UI thread.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 14
(2,646 Views)

Is there a work around this?

0 Kudos
Message 10 of 14
(2,636 Views)