01-15-2019 10:24 AM
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.
Solved! Go to Solution.
01-15-2019 12:08 PM
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.
01-15-2019 12:34 PM
Set Wait until complete to false and use a .bat file?
Ben
01-17-2019 12:47 PM
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.