• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 927
  • Last Modified:

Scheduled reboot if User is Logged Off

Hi guys,
I am looking to set a scheduled task on all PCs to reboot provided there is nobody logged onto them.

Is it possible to run a simple script to check the status of the PC and then reboot if noone is logged on?

Thanks in advance
  • 2
1 Solution
Pradeep DubeyConsultantCommented:
you can use below script to shutdown the machine
@echo off
qwinsta | find "Active"
if %errorlevel% == 0 shutdown /p
if %errorlevel% == 1 echo No

Open in new window

run this script in a schedule task.
Pradeep DubeyConsultantCommented:
you may use this script to run at logoff.  This will be better idea.
aidebAuthor Commented:
Works 100% and nice and simple!

If there is an easy way of returning the logged on user can you advise? I have added some logging round this and the username would be nice to have.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now