LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop a running vi from another vi

Hello,

 

I want to know if there is a way I can perform a external Abort on a already existing VI running VI? The VI is built as a executable file for a touch panel and is in the Startup folder. I have a executable file which deletes an existing executable file from start up and replaces it with an updated file, however, because the VI is running at the time the file never gets deleted. If anyone knows a way that would be really helpful.

 

Thanks

 

 

0 Kudos
Message 1 of 8
(4,401 Views)

Hello T_P_Tithering,

 

It sounds like your abort command needs to be sent from a separate application- this is a bit tricky, but can be done via VI server if you enable it for the application during the build.  You can use the standard application methods and properties once you've created a reference by name or port.

 

The quick and dirty (and external) way is to use the windows taskkill <application>.exe from the command prompt (system exec.vi)

 

Regards,

Tom L.
0 Kudos
Message 2 of 8
(4,396 Views)

Hello,

I don´t know if using VI server will help you with that, I think there´s no way to stop an *.exe using the VI server because is now an independent app. However you can always check if there´s an invoke node to do so (but I think there´s nothing)

However, I have another idea. You can send from LabVIEW command lines to the command propt, so you can stop the *exe directly from terminal. The VI that invokes the cmd and writes command lines to it is called  System_Exec.vi.

0 Kudos
Message 3 of 8
(4,392 Views)

Cheers Tom,

 

I'm not sure if the VI server was enabled on the system but I've started implementing your idea. I'm going to try and stay clear of going through the command prompt. Here's what I have so far but I didn't see a abort sequence and the closes thing is Close after calling.

 

I appreciate the help 🙂

 

0 Kudos
Message 4 of 8
(4,383 Views)

Sorry to ask but what would be the correct syntax for the command line to perform a taskkill. From what I see its taskkill /f/im /*exe but the help file says I need to put cmd c/ before my command. I also have the working directory linked to the VI i want to kill.

0 Kudos
Message 5 of 8
(4,361 Views)

Oh hang on I found this link. If its a single vi will it close all of labview or just the VI?

0 Kudos
Message 6 of 8
(4,353 Views)

Yeah it doesn't seem to be stopping the VI.

0 Kudos
Message 7 of 8
(4,348 Views)

I've not checked the syntax requirements for the command prompt method, but I've attached a quick demo below using the VI server/ActiveX method.  Please keep in mind that this is a proof of concept and anything you use in a deployed application will need a bit more work (error handling and better logic to select the VIs you want to abort and/or close at a minimum) before it's suitable for any sort of real-world use.  The "abortable" exe is included in the zip file, but if you need to recompile it I've provided the configured project/build spec as well.

 

Run AbortMe.exe and then run the remoteabort VI.  One thing worth noting is that if there are multiple instances of the abortme service launched (via LabVIEW, or another EXE that tries to use that service name), the service names will be duplicated and you'll only be able to abort the first service launched.  The service locator is also application-context based, so if the abortme vi is launched outside of the project or exe, it wont be found using that service name. I stuck in an AppName indicator that will let you know what application you're attempting to access.

 

This will only work if the VIs you are trying to access/stop have been exported as part of the build.  The build spec I've provided has exported all included VIs, but this isn't probably necessary (or even a good idea) in a larger project.

 

-edit- Attachment didn't take.

 

Regards,

Tom L.
0 Kudos
Message 8 of 8
(4,318 Views)