10-20-2022 06:57 PM
Can someone tell me the password to open the block diagram of System Exec.vi?
Or, how that vi works, so that I can write my own?
I sometimes need the standard error to be inline with the standard output, not separated.
10-20-2022 07:58 PM
You realize that having a password implies that the information is confidential (with NI), don't you? Instead of trying to "crack" NI's intellectual property, why don't you just execute System Exec, get the strings you want, and format them as you want them to be? You can call the VI "Corey System Exec" ...
Bob Schor
10-21-2022 07:36 AM - edited 10-21-2022 07:43 AM
There is nothing in that VI that you could change. All it does is a Call Library Node that calls a LabVIEW internal C function. So there is absolutely zero things you can improve, every possible change you could make you can also make by massaging the input values properly before calling this function, or ignoring or altering certain return values from the function.
Creating your own System Exec "only" requires you to do some Windows API functions. The whole thing centers around the Windows CreateProcess() API and some extra glue code to install standard IO streams that you can redirect to your own strings. If you really really want to get your hands dirty, you can take a look at the OpenG Pipe IO library and the underlaying DLL source code here. But beware, bears and other dangerous animals are ahead.
Or you look for one of the several System Exec LabVIEW libraries that use the .Net API to do something similar. Definitely less of work and likely can do what you want as well.
10-21-2022 09:53 AM
I have several different versions of System Exec... and they are all wrappers that simply "hide" some extra steps after calling NI System Exec.
10-21-2022 11:43 AM
Yup, not much to see here.
10-21-2022 12:51 PM
Hi Darren,
once there was a recommendation to place controls/indicators outside of any structure when they are tied to the connector pane: maybe NI had to password-protect that VI because of (not obeying) that recommendation!? 😄
10-21-2022 12:54 PM
Yup, this VI is definitely violating more than one of our style guidelines. Check out how honest I was in posting that picture without habitually cleaning up the diagram first? 😉
And yes, for performance reasons, those terminals should definitely be on the top-level diagram. But I'm hoping there's not too many instances of people calling System Exec.vi in a tight loop...
If I were still in R&D I would have already submitted the cleaned-up VI.
10-21-2022 01:45 PM
There is noway to call this in a tight loop. Process creation under Windows is a very costly operation that takes a rather long time (in terms of computer code execution). Linucx is more lightwaight, especially for cli’s.
10-21-2022 01:56 PM - edited 10-21-2022 02:05 PM
Maybe at one point it could be upgraded to use PowerShell instead of cmd. (Not really sure what's under the hood now...)
10-21-2022 03:02 PM
Unless you call cmd.exe yourself in the command to SysExec, no cmd is involved. This function directly calls CreateProcess() Windows API and closer to the kernel than that is not really possible without resolving to call semi private kernel APIs directly.
PowerShell ultimately has to call this function too or it may even call ShellExecute() which is even further away from the kernel (but has certain extra features such as allowing for elevation).