Display message box that prevents computer shutdown until acknowledged

0

Since I always forget to close my window at work, I'm trying to display a small message box to remind me when I shut down my computer.

The script is easy enough:

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show('Close your window', 'LogOff Reminder', 0)

The problem is, I can't get my system, windows 10, to run it at shutdown. I tried setting up a policy with gpedit.msc. I also tried setting up a task with taskschd.msc.

I have two ideas what the problem might be:

  1. The point in time when the script is run is already to late for graphical feedback, the system is already shut down to far.
  2. My system doesn't do a real shut down, but merely hibernates in support of fast boot.

Has anybody ever gotten this to work? Could you point out how?

Thanks in advance!

Ruben Bohnet

Posted 2018-05-25T12:27:12.307

Reputation: 101

1Shutdown scripts run in SYSTEM context, not USER context. You won’t see any output from something running in SYSTEM context on a user’s screen. In task scheduler you may be able to fix this with the “run as logged on user,” option. You also can’t prevent a shutdown by simply displaying a prompt on the screen. I imagine there is a way to interrupt or delay the shutdown but not by just displaying a prompt. I also know shutdown scripts usually run after the user session has ended. – Appleoddity – 2018-05-25T12:37:38.510

@Appleoddity Thanks for dropping some extra buzzwords for me to research. I will check back in, if I find something in that direction. – Ruben Bohnet – 2018-05-25T12:51:07.633

Answers

0

Not sure if you are talking about automatic or manual shutdowns, but you could create a script that you use to shutdown your computer instead of the shutdown button on your machine. You could use any language like powershell, vbscript, or batch to accomplish. You can then prompt yourself to save before clicking shutdown. You could also put it in the system tools folder and create a super secret shortcut for it like Ctrl + Alt + Shift + S.

WIN10: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools

Hyperlite1215

Posted 2018-05-25T12:27:12.307

Reputation: 11