10-18-2013 02:49 AM
Hi,
is there a way to avoid that an exe can be closed via the windows task manager?
I´ve tried the "Application Instance Close?" Event but this does not work.
I need to show a dialog to the user when my LabVIEW application wants to be closed from the Task Manager.
10-18-2013 04:11 AM
There's no way to do this from labview, windows will just abort/kill your application if you close if from task manager, it doesn't care about you trying to process events in labview.
Like if you pull the plug from your computer, but want a dialog box to appear in windows asking if you really want to shut it down.
The application instance close will handle you using the X button in the top right to close the application main window.
Make sure your program handles window closes if you need to do anything before shutdown (such as restoring hardware to safe states).
Unfortunately if you end user wants to kill it with task manager, you can't do much about it.
10-18-2013 04:26 AM
Hi,
thanks for your post.
But the "Application Instance Close?" Event does not handle pressing the "X" on the Front Panel. Also it does not handle the right click on the task bar application icon and selecting "close window".
For this the "Panel Close" Event is the one that is executed.
The only way i see the "Application Instance Close" event is, when closing the Application with Ctrl + Q.
regards,
Daniel
10-18-2013 05:07 AM
Yes I checked and misunderstood a bit.
You are right, the application instance close is fired when you basically execute the quit labview/quite application command from the menu as you say.
It was the panel close I was thinking of for the X button.
10-18-2013 05:33 AM
Hello Again,
when closing an application from the task manager there are two different ways.
1. Killing the process:
--> Task Manager - Processes Tab - End Process
2. Closing the Task
--> Task Manager - Applications Tab - End Task
Killing the process can not be avoided, but closing the task should generate an event that can be catched i think.
10-18-2013 06:26 AM
You could consider some workarounds:
- Run your Labview .exe as a Windows service (http://digital.ni.com/public.nsf/allkb/21BA0F671A63A60386256CB4004DF99B?OpenDocument). Of course if your user is the pc admin, then this is useless.
- Keep a second process monitorig the status of the exe and restarting it if it's closed
- Hide the exe from Task Manager (...but i'm afraid this is not possible...)
Marco
10-18-2013 08:04 AM
I also had this idea, but when the application was closed its already too late.
In other programming languages i thought it is possible to receive an event when the task has to be closed.