05-18-2022 01:04 AM
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.
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
Solved! Go to Solution.
05-18-2022 01:26 AM
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.
05-18-2022 01:48 AM
Did you set the "wait for completion input (T)?" to True?
05-18-2022 01:50 AM
I had the same Idea and even I tried JKI dot net exec but still I am facing the same issue.
05-18-2022 01:51 AM
Yes, I have. However I am getting the error stating that pnputil is not an operable command. Where as it works in cmd.
05-18-2022 02:02 AM
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.
05-18-2022 02:18 AM
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.
05-18-2022 02:25 AM
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.
05-18-2022 02:32 AM - edited 05-18-2022 02:44 AM
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.
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.
05-18-2022 02:43 AM
Is there a work around this?