We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


How to force a reboot based on uptime

Medium Priority
Last Modified: 2012-05-11

Has anyone found a way to force a laptop or desktop Windows-based computer (XP, 7) to reboot after a period of time.  For example, I would like to implement something that works like this: If the system is up for X amount of days, a message comes up telling the user he needs to reboot based on the policy.  Roughly 66% of our workforce is using laptops and I'm sure a lot of them are simply hibernating nightly instead of rebooting.  This has caused some problems with software we push that require reboots.  Has anyone does anything similar to this?  I'm sure the other option is to disable the hibernate and log off buttons using group policy but I want to try to avoid that at the moment.
Watch Question


Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


That script looks interesting, but I think I see an issue with it.  We have a lot of users who work nights and weekends for system maintenance purposes.  Unless I'm reading it wrong, it looks like the script will reboot the machine if the user is actively logged in.  Have you implemented this in production, Gem1n1?

I noticed that as well.  I think a little modification in the reboot subroutine to generate a pop-up prompt would solve that issue.

I have not implemented this exact script in production because we use group policy, WSUS, and SCCM to enforce reboots after important updates.  My company is all laptops for everyone so we had to come up with a more detailed solution.


Alright, thanks G3m1n1.  I was hoping for more of a supported or Group Policy solution, but I think this will work.  I'll take your script, modify it and make it work for our environment.  Thanks for your help!


I gave it a B only because the solution wouldn't work for us as-is.  It'll require modification of the code to make sure logged in users don't get booted off.
Tried this script and get an error at line 121 about a variable not being set (see first attachment). I comment out the line and run it again to get a message "privilege not held" (2nd attachement). Tried letting task scheduler run it with "highest privilege" but same messages come up. The account I login with does have administrator rights.

What am I missing?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.