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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.