Prevent Windows 7 users from canceling shutdown (disable shutdown -a)
Solution 1:
This question has 2 different answers. One that directly answers your question, and one that is how you should be setting this up.
Solution to your question
You cannot prevent a user to abort a shutdown with a timer, but if you change the shutdown to -t 0 (immediate shutdown) it cannot be prevented with a shutdown -a command. You could therefor initiate a 2nd task that runs 2 minutes later that will do a shutdown -s -f -t 0 to shutdown the pc. The user will first see a timer of 2 minutes and even if they abort it, the system will shutdown 2 minutes later.
How you should solve this
Windows offers Parental Controls with logon hours. Setting this up will log the user out when the logon time has expired. Unlike with your solution, the user cannot simply turn on the pc and/or log back in. If they try to, they'll get a message: logon hours have expired. Wait until you are allowed to login again.
To set this up, do the following:
- Go to
start
->Control Panel
- At the top right, Set
View by
toCategory
if this is not already done so. - Click on
Set up parental controls for any user
. - Click the user that you want to limit.
- Set Parental Controls to
(x) On, enforce current settings
- Click
Time limits
- Draw/fill the blocks where the user is not allowed to use the computer. You can use drag/drop from the top left corner to fill in a big area of blocks.
- Click on Ok to make this final.
Thats it. The user will be warned prior to being logged off.