LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SysExec (cmd) : Run as administrator

Solved!
Go to solution

Depends where you see 42! The VI is so programmed that if ShellExecute returns a value smaller or equal to 32, it will return an error 42 in the error cluster and a string "ShellExecute error xx" where xx is a number that is the value returned from the ShellExecute function.

 

So if ShellExecute returns 42 everything is fine. But if the VI returns error 42 I would like to know the xx value in the error string. And yes 0 return value from ShellExecute would indicate out of memory condition during execution of ShellExecute.

Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 14
(809 Views)

Yes!  The 42 is coming back from the Call Library node directly, it is not the 42 you are inserting if Call Library returns ..32.

 

How inconsistent to use 0 for an error condition!

0 Kudos
Message 12 of 14
(804 Views)

@FermWorks wrote:

 

How inconsistent to use 0 for an error condition!


That's for historical reasons. In Windows 3.1 the function did return a HINSTANCE value which was a handle that could be used to access the spawned process. Since this value could be almost any possible value the developers reserved the value range from 0 to 32 for some error codes and anything above was a HINSTANCE. Currently the function returns still the error codes range when something goes wrong, but not really a HINSTANCE that could be used to identify the child process. Instead it simply is documented to return a value that is higher than 32 but which can not be used for anything else. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 13 of 14
(797 Views)

Hi Rolf

Thanks for putting together the VI with the CLFN in it. That's gotten me most of the way to what I was looking for. I need the "wait until complete" functionality and took your advice to start looking into ShellExecuteExA... and I gave up. I might give it a try again later and if I do I'll post my solution. 

 

Thanks again.

0 Kudos
Message 14 of 14
(769 Views)