LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System Exec.vi wait until completion

I have a vi that uses the System Exec.vi to run a command line program from Atmel (atprogram.exe). Our current code has "wait until completion?" set to True and uses the standard output from the command line to see the output of atprogram.exe to confirm that the command completed OK and to get data back from atpgrogram.exe.

 

This vi has worked fine on four computers for a while. I tried yesterday to run the same program on a new computer and I keep getting an error. It appears the System Exec.vi is returning an error with a traceback that ends up with "WindowsError: [Error 6] The handle is invalid". This appears to maybe be something with a GUI, although atprogram doesn't use a GUI; anyway, that may be specific to atprogram, the point is it gets some type of error.

 

When I set "wait until completion?" to false the System Exec.vi runs the command fine and atprogram.exe does its job. The problem is then I don't get the standard output that I use in the rest of my vi to process data that comes back.

 

I have verified that running the string that is passed into System Exec.vi works fine just pasting it into a windows command prompt. And as I mentioned the command runs fine if the vi doesn't wait for completion.

 

Does anyone have ideas what to look for? It does seem like something specific to the computer that is causing the problem. But the wait until completion seems to affect it too.

 

 

 

Message 1 of 6
(3,381 Views)

Kudos for the thorough explanation. 

 

I would try playing with the privileges, can you run your LabVIEW program as administrator?

 

Is there an antivirus program installed that you can temporarily disable?

0 Kudos
Message 2 of 6
(3,372 Views)

Can you show how you are making the call?  Create a snippet (Edit->Create VI Snippet) and post the resulting image file.  I'm wondering if you are specifying the path to the VI correctly.  Maybe on the old computers, the path to the EXE is in the PATH environment variable and so you only need to provide the name of the exe in that case. 

 

Also could it be that the EXE was developed for 32bit and you're now trying to run it on 64bit (or vice versa)? 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 6
(3,340 Views)

While I have no idea what could be causing the problem, I can suggest a workaround.

 

If your command is something like this:

 

cmd /c dir c:\

You can redirect its standard output to a file instead by reformatting the command:

cmd /c dir c:\ > C:\Users\myusername\Desktop\dir.txt

Just add some LabVIEW nodes beforehand to delete the target file if it exists, then look for the file after it finishes.

0 Kudos
Message 4 of 6
(3,314 Views)

@aputman wrote:

Can you show how you are making the call?  Create a snippet (Edit->Create VI Snippet) and post the resulting image file.  I'm wondering if you are specifying the path to the VI correctly.  Maybe on the old computers, the path to the EXE is in the PATH environment variable and so you only need to provide the name of the exe in that case. 

 

Also could it be that the EXE was developed for 32bit and you're now trying to run it on 64bit (or vice versa)? 


I believe you're looking at the problem backwards. The VI already knows its own path.  It's using the System Exec call to reach out to the command prompt.

 

By testing the string he's using in the VI directly in the command prompt, he's verified the pathing you're questioning (unless the command prompt opens up differently between LV and the OS itself).  By running this script from the command prompt, it eliminates concern with respect to bitness.  The OS can run the EXE.

0 Kudos
Message 5 of 6
(3,285 Views)

One more thing I might throw in the mix to this pot of spot on troubleshooting ideas--is there anything obviously different about the fifth computer and its environment? Since the program is throwing a Windows error I'm wondering if it's something to do with permissions or the build of the computer itself. Do you see a LabVIEW native error at all?

 

 

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 6 of 6
(3,245 Views)