LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you STOP an external application from running using Labview

Labview is used to start an external application by using system exec (which has several issues). How would you stop the same or other applications from running using Labview.
 
George
0 Kudos
Message 1 of 7
(4,503 Views)
LabVIEW 8 has an example using ActiveX to open and close a spreadsheet:
labview\examples\comm\ExcelExamples.llb

- Greg
0 Kudos
Message 2 of 7
(4,496 Views)

Thanks to Greg for his reply.

Unfortunately I am using LV7.1 and I really need an inverse "SYSTEM EXEC.vi" Something that can stop any application like sysexec can start any application.The programs I need to control are not set up for ACTIVE-X (unless they don't have to be).

 

George

0 Kudos
Message 3 of 7
(4,483 Views)
In Windows XP, try the C:\TASKKILL command.
(type taskkill /? at the command prompt for usage instructions.)
for example, if Notepad is running,
C:\TASKKILL /IM notepad.exe
will close notepad.

It works at the Command Prompt, but I haven't tried it in LabVIEW yet. Will let you know.

- Greg
0 Kudos
Message 4 of 7
(4,477 Views)
Normally, it's fine to open the app by running the executable.  But as for shutting it down, it's better to do it gracefully, i.e., either selecting the File >> Exit, or any button provided for this purpose, etc.  This will allow the program to do whatever clean-up it needs to do before quitting.  TaskKill, on the other hand, is like yanking the plug. 
 
There's no way for LabVIEW itself to know how to stop an executable.  So, you have couple of options:
1.  If you have the API for the program, you may want to call its 'shutdown' function, if present. 
2.  If it's a GUI program, you could try sending KeyStrokes to click that Exit menu/button.  I know, not elegant.
 
If the above aren't really options, TaskKill it is!
 
-Khalid
0 Kudos
Message 5 of 7
(4,473 Views)

George,

All you need to do is find the window handle of the application.  Try lvwutil32.zip on NI website.

See http://digital.ni.com/public.nsf/allkb/2986FC3AE5CC1E3C86256C3F006EE656

 

George Zou

http://gtoolbox.yeah.net

George Zou
Message 6 of 7
(4,463 Views)

Thanks to all for responding

So far, I tried the window handle method. It works. It looks like you can close any open window app. Essentially an inverse SYSEXEC.vi.

This solution was from George Zou.

 

George Belva

0 Kudos
Message 7 of 7
(4,435 Views)