From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System Exec.vi with Timeout

Solved!
Go to solution

I'm using a vi to pull data from a device. In order to pull data from the device I have to run a process that enables communication with the device. So the vi is ordered to start the communication process, pull data, than close the process window. The issue, is that this process runs until you manually stop it and there doesn't seem to be anyway to stop a system exec.vi automatically. The only work around is using taskkill /f /im cmd.exe to kill the window, but this is far from ideal because I'm expecting to be communicating with multiple devices and running multiple instances of this vi and I don't want them to be closing each other out or stopping the wrong process. I want each vi to target it's own system exec.vi/console window specifically. 

A timeout would be perfect. I could just set the time with an appropriate amount of time to let the vi pull data and then it would close itself. However, I can't find any way to do that. I've tried timed sequences and event structures and they all wait for the exec.vi to finish - which is never. I even tried aborting the overall vi, but the process console window still runs even if the vi doesn't.

 

Does anyone know an effective way to stop a specific instance of system exec.vi with a timeout or command?

 

I can't share my code for legal reasons but I uploaded the basic premise.

Download All
0 Kudos
Message 1 of 4
(3,388 Views)

I would suggest trying to do this via .NET.  Check this link for some useful information.  I posted a link there to Stack Exchange for running CMD in a text based language.  Should be easy enough to translate to LabVIEW code. 

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 2 of 4
(3,353 Views)

Set Wait until complete to false and use a .bat file?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 4
(3,344 Views)
Solution
Accepted by topic author MattManML

So after searching awhile I figured out a way around timing out System Exec.vi. 

By using the command: start "name" [command] - I can run the command through a window with a specific name. Then later I can use: taskkill /f /fi "WINDOWTITLE eq name" - to close. That why I can have the program generate a unique name so they don't interfere with each other.

Thanks for your suggestions.

Message 4 of 4
(3,309 Views)