1

just wondering whether its possible to run a script when Windows turns the screen off after a period of inactivity (not sleep or hibernate but just switching off the screen) as well as when the user wakes the computer back up, if so how?

Thanks.

4
  • 2
    If the script runs via Task Scheduler or like, it will run when the screen is off (computer ON, screen OFF). If you log in from another computer, the screen will turn ON.
    – anon
    Commented Sep 15, 2021 at 13:24
  • Sorry I should of been clearer in my question. I only want the script to be run at the moment when the screen turns off, the same goes for when it gets woken.
    – George
    Commented Sep 15, 2021 at 13:34
  • You need to review event logs and I added some information on that as well.
    – anon
    Commented Sep 15, 2021 at 13:38
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Sep 15, 2021 at 15:50

1 Answer 1

0

If a Windows computer is running (not suspended) and the screen turns of as a result of Windows Power Management and (possibly) the screen settings, then Windows is still running.

Scripts run via Task Scheduler or like will run. Updates will run. Actions like restart from Update will start up the screen.

Also if you remote in from another computer, the screen will turn on.

So there are some variations, but the computer will run scripts if the screen is off.

If you wish to try running a script resulting from a power event, you need to check the event logs.

Please see: Display all power related events (turn-on/-off/sleep/hibernate/...)?

If all this does not work (and I suspect not) then you most likely cannot do what you want. I have not run across any request (hundreds of customers) who need to be alerted when the screen turns off.

5
  • Thank you! Couldn't find a way to log screen turn off and windows not showing it in report but have done the same using a screen saver instead.
    – George
    Commented Sep 15, 2021 at 15:07
  • I suggest looking through this Microsoft Article: docs.microsoft.com/en-us/windows/win32/power/… ... In my years of consulting and hundreds of people, I have not come across this specific request.
    – anon
    Commented Sep 15, 2021 at 15:17
  • Had a read through and it all seems to do with sleep and wake for the power statuses. The only mention of turning off the screen is in power schemes but nothing more than that. I did generate a report with powercfg.exe and even though I could filter by screen off it showed no logs of the event occurring. Can't find anyway to enable logging in group policy either like you can with screen savers, very strange.
    – George
    Commented Sep 15, 2021 at 15:52
  • I don’t think there is any way to do what you want as it is a uncommon problem.
    – anon
    Commented Sep 15, 2021 at 15:56
  • Yeah, thanks for your help though as I've managed to achieve what I was wanting to do.
    – George
    Commented Sep 15, 2021 at 16:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .