Making a task to shutdown the PC when no one logs in for 5 minutes

1

I'm trying to find a way to shutdown my PC when it starts up and no one logs in for 5 minutes (or some other specified time).

I've found similar tasks that try to shutdown the PC when it is idle.

The problem is that if an antivirus program or anything else is running in background, then these tasks don't work because the the PC is "never" idle.

My system is running Windows 8.1.

Ramon Castañer

Posted 2018-08-03T09:19:58.873

Reputation: 11

Use Task sheduler. Insert shutdown /s /f /t 300 task with a trigger of "system starts" plus a trigger of "user logoff" and shutdown /a task with a trigger of "user logon". All tasks must be executed with administrator account. PS. Sorry, I cannot find real names of events in english. – Akina – 2018-08-03T09:26:28.307

@Akina sounds like an answer to me. Why not submit it as one? OP can then accept it if it works, and we all know he doesn't need further help. – LPChip – 2018-08-03T09:46:00.727

@LPChip I have never tested cross-user shutdown. I am not sure that it will work correctly. And I don't want to test it. – Akina – 2018-08-03T09:47:24.933

@Akina it will work fine. It's OK to post an answer you've not tested. You can state this in your answer so others are aware you haven't tested it. – I say Reinstate Monica – 2018-08-03T11:13:57.840

@TwistyImpersonator I am afraid it will not work correctly in a scenario: user1 logged in, user2 logged in using fast user switching, any user log off... 5 min and shutdown. – Akina – 2018-08-03T11:27:12.680

1@akina The OP didn't mention having the system shut down 5 minutes after a user logs off...Only 5 minutes after the system starts (If no one logs on). Trigger the shutdown at system start, and cancel the logon when any user logs on. That will work and be what the OP asked. – I say Reinstate Monica – 2018-08-03T11:30:33.240

@TwistyImpersonator Maybe you're right... I edit my answer. – Akina – 2018-08-03T11:36:14.303

Answers

2

Use Task sheduler.

Insert a task with action of

shutdown /s /f /t 300 

with a trigger of "when system starts" (and maybe plus a trigger of "when user log off").

Insert a task with action of

shutdown /a 

with a trigger of "when user log on".

All tasks must be executed under Administrator account (enter its password when promted).

PS. Sorry, I cannot find real names of events in english.

PPS. I have no tested this solution.

Akina

Posted 2018-08-03T09:19:58.873

Reputation: 2 991

You'll probably want to run the shutdown /a from a batch file in the Startup folder instead of via Task Scheduler. The latter will want you to specify which user must logon to trigger the task, forcing you to create one task for every user. – I say Reinstate Monica – 2018-08-03T11:33:27.033

@TwistyImpersonator That's right too. Thanks. – Akina – 2018-08-03T11:38:05.820

+1 for posting the answer. :) – LPChip – 2018-08-03T11:53:36.207

0

@Akina, It works fine with the two tasks, one to make the shutdown and the other to stop it if someone logs in. I used task scheduler.

THANK YOU SO MUCH.

I wanted to make this task because these days I have a problem: When I shutdown my PC sometimes it appears a driver_power_state_failure that I can't not resolve. The PC restarts itself when the error arises. I would have programmed an automatic hibernation (S4) but I prefer a real shutdown (S5) because my motherboard is a little bit old. I couldn't wake the system with WOL when it is in S4 state but now I can wake it because it shutdowns at S5 state.

Thank you very much again.

Ramon Castañer

Posted 2018-08-03T09:19:58.873

Reputation: 11