Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task Scheduler Application Exit Trigger

I'm writing (win7) kiosk software and I want to schedule a "shutdown" bat to run whenever my application exits (Crashed, "Hacked" or Normal Exit) under a specific user account with the task scheduler.

How can I create the application closed trigger though?

If it's not possible, my fallback plan is to have some kind of monitor begin in the Application start event but I'm thinking that if my hypothetical hacker could close the main application whats to stop them closing the Monitor process?

EDIT: Currently the app is loaded under an excessively limited profile with the "runas" directive impersonating an admin user. If the task schedular could be triggered I can also run this batch file from the administrative account on app closure.

like image 262
Dead.Rabit Avatar asked Sep 10 '26 03:09

Dead.Rabit


2 Answers

I have an idea.

When your application start you create a schedule of shutdown after 1 minute. And In your application you can set a timmer to delay the schedule periodically. Once your application down and no one delay the schedule so the machine shutdown. Also you should delete the schedule on a normal exit

like image 100
horsley Avatar answered Sep 11 '26 19:09

horsley


Maybe you could have your kiosk application create and own a global mutex, and have the monitor application wait on the mutex. The monitor application can be a service so you don't have to worry about starting it from your process. When your application terminates, the monitor will get ownership of the mutex, and as a bonus, if your process terminated unexpectedly (ie does not ever release the mutex properly), then monitor application will have a AbandonedMutexException thrown to it. So you'll know if it was a normal shutdown, or a crash/kill. You can run the monitor app under an account with the necessary privileges to do whatever shutdown work is needed.

like image 45
S T Chan Avatar answered Sep 11 '26 21:09

S T Chan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!