LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

automatic LabVIEW closure?

Is there a way of automatically stopping and properly closing a Labview program (which is transparent to the user) without any prompts when the user shuts down their computer?

Thanks!
0 Kudos
Message 1 of 5
(3,195 Views)
The Quit vi which is under application control will close LabVIEW properly. Program what event you want to cause the shutdown.
0 Kudos
Message 2 of 5
(3,195 Views)
I have found the exit.vi - I guess my problem is how do I register the user shutting down or restarting the computer - I have looked through the many windows system utilities vis and nothing seems to be able to
monitor this.

Thanks for your help.
0 Kudos
Message 3 of 5
(3,195 Views)
There is another thread on this forum with information about monitoring crashes (just search for Monitoring Crashes) that may have some information about some third party software that could help you. However; unless this software is able to message LabVIEW somehow, it won't help. Additionally, it was indicated that this software only monitors crashes, so I don't know if it will handle shutdowns too.

Other than that, I can suggest looking at Microsofts (worthless) website for information, or else MSDN (copies of which can be gotten on eBay pretty reasonably these days.)

Is there a reason you need this functionality? Are you trying to shut down a program that runs in the background without the user knowing? Windows should shutdown yo
ur program cleanly for you when it shuts down.
0 Kudos
Message 4 of 5
(3,195 Views)
JAI wrote:
> Is there a way of automatically stopping and properly closing a
> Labview program (which is transparent to the user) without any prompts
> when the user shuts down their computer?
>
> Thanks!

In LabVIEW 6.1, there is an Event in the Event Structure called
"Application Exiting". This seems like it should be a fairly direct way
to do what you want. However, experimenting with it, it took me a while
to arrive at a solution.
I wrote a VI that has this event, along with a timeout event, in a
loop. If the "App Exiting" event fires, then another case structure
executes that calls the "Exit LabVIEW" function.
If you just use this event, then shut down windows, the event does
successfully fire, but one of two things happens. If the Discard option
is set to False, then after LabVIEW exits, Windows does not shut down,
as the event was discarded. If Discard is set to True, then you get a
LV dialog asking if all running VI's should be shut down. Regardless of
how you answer, Windows does not actually shut down! (This is using
W2K, SP2.)
Here is what I worked out. Set Discard to True. This eliminates
the pesky dialog that you don't want the operator seeing. Then, instead
of calling Exit LabVIEW, use the LVWinUtil library and call an exit
Windows function.
With this solution, I was able to write a program that would detect
when Windows was trying to shut down, it would then have a chance to do
whatever it needed to do to clean itself up, and then it would shut
Windows down itself.
Is this what you need? Let me know if you would like the VI.
It seems like this should be possible without using the LVWinUtil
library. If anybody knows what I am doing wrong and how to get this to
work using just the built-in LabVIEW functions and event structures,
please let me know.

Regards,
Dave

-------------------------------------------------------------
David Thomson 303-499-1973 (voice and fax)
Original Code Consulting dthomson@originalcode.com
www.originalcode.com
National Instruments Alliance Program Member
-------------------------------------------------------------
Research Scientist 303-497-3470 (voice)
NOAA Aeronomy Laboratory 303-497-5373 (fax)
Boulder, Colorado dthomson@al.noaa.gov
-------------------------------------------------------------
Message 5 of 5
(3,195 Views)