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
- Go to the control panel, User Accounts.
- Click Manage another account
- At the bottom choose Set up Parental Controls
- Either select his user with limited rights, or if there's just one user, press the Create a new user account link.
- Select the limited uesr
- Click On, enforce current settings
- At the right, select the Off link besides Time.
- 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
- Go to the control panel, administrative tools, Task Schedular.
- Click below Task Schedular (Local) on Task Schedular Library.
- On the right, Choose Create Task...
- Give it the name `Automatic Shutdown
- Go to the tab Triggers
- Press New...
- Either select Daily (every day) or Weekly (to specify which days)
- At the top right, select the time the pc has to automatically shut down.
- Press OK.
- Go to the tab Actions.
- Press New...
- Below Program/script: enter the following
shutdown
- 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.
- 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:
- Start menu --> Type "Task Scheduler" --> Open Task Scheduler.
- Create New Task
- Set these properties in the General tab:
- Name: choose a task name
- Check Run only when user is logged on
- 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
- 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)
- In the Conditions tab:
- Uncheck everything
- 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.