Is there a way to shut down and lock a pc at a predetermined time?

I have a 14 year old boy who's obsessed with his gaming pc so much that he stays awake all night sometimes and sleeps all day. Normally that would cause havoc with his schooling but he's being home schooled where he lives with his mother but is there some way to make the computer unusable after a certain predetermined time we can set so his pc shuts off say at 10:00 pm and won't start till 7:00 am?


Solution 1:

The best way is to setup Parental Controls to limit logging in, and a scheduled task that'll shutdown the pc at the time he must go to bed.

To setup parental controls

  1. Go to the control panel, User Accounts.
  2. Click Manage another account
  3. At the bottom choose Set up Parental Controls
  4. Either select his user with limited rights, or if there's just one user, press the Create a new user account link.
  5. Select the limited uesr
  6. Click On, enforce current settings
  7. At the right, select the Off link besides Time.
  8. In the new dialog, select which hours he is allowed to be on and which hours he is not allowed to be on.

To setup automatic shutdown

  1. Go to the control panel, administrative tools, Task Schedular.
  2. Click below Task Schedular (Local) on Task Schedular Library.
  3. On the right, Choose Create Task...
  4. Give it the name `Automatic Shutdown
  5. Go to the tab Triggers
  6. Press New...
  7. Either select Daily (every day) or Weekly (to specify which days)
  8. At the top right, select the time the pc has to automatically shut down.
  9. Press OK.
  10. Go to the tab Actions.
  11. Press New...
  12. Below Program/script: enter the following shutdown
  13. To the right of Add arguments enter: -s -f -t 10 (the -t 10 gives a 10 second countdown before the shutdown starts. Note that you can abort a shutdown by entering shutdown -a. If you want to prevent being able to block this, change to -t 0 which makes the shutdown immediate. A second task that starts earlier can be to display a message.
  14. Press OK. and OK again.

Thats it.

EDIT: I just tested the parental controls. If the user is not allowed to be on, windows will automatically log off the user. The user can't log in until they are allowed again, and the user has a shutdown button to shut down the pc. Any open programs/games will not save correctly, but thats also what the scheduled task will do.

Solution 2:

In case someone doesn't want to set up parental control (someone wants to lock the computer from themselves, not their kids), here is another solution using only Task Scheduler, which I'm currently using:

  1. Start menu --> Type "Task Scheduler" --> Open Task Scheduler.
  2. Create New Task
  3. Set these properties in the General tab:
    • Name: choose a task name
    • Check Run only when user is logged on
  4. In the Triggers tab:
    • "New..."
    • Beginning the task: On a schedule
    • Settings: Daily
    • Set the hour you want to turn off your computer
    • Check Repeat task every: 5 minutes for a duration of 1 hours (or 8-9 hours, depending on you)
    • Check Stop all running tasks at end of repetition duration
    • Check Enabled
    • OK
  5. In the Actions tab:
    • "New..."
    • Action: Start a program
    • Program/script: powershell.exe
    • Add argument: -command add-type -assemblyname System.Windows.Forms; [System.Windows.Forms.Application]::SetSuspendState([System.Windows.Forms.PowerState]::Suspend, $false, $false)
  6. In the Conditions tab:
    • Uncheck everything
  7. In the Settings tab:
    • Uncheck everything

This schedule will put your computer to sleep at the chosen time. If you try to turn the computer back on, it will continue to sleep every 5 minutes (in 1 or 9 hours - depending on your setup). This sleep action cannot be prevented. The computer went sleep, not turn off, so no worry about unsaved work.

Note: there is no warning display before the computer goes to sleep. You can create another Task Schedule to remind you of sleep time.

Solution 3:

I believe you could do this by changing the local accounts logon hours then setting a local GP to force logout when they expire.

net user [user] /times:m-f,08:00-17:00

My command allows [user] logons Monday to Friday from 08:00 – 17:00 local time.

Then go into gpedit.msc and set the policy linked below: http://technet.microsoft.com/en-us/library/jj852195.aspx

*Note it won't shutdown the PC it'll log user out, you could find a LGP for that as well maybe.