net user /time is very hard to work with. It requires using net time to calibrate the time, and in emergencies you need to use the network to run psexec for remote unlocking. Also, once the user changes the login method from XP's welcome screen to the classic login screen, the method of logging off to lock the desktop stops working. All of these plans are just making trouble for yourself, annoying. Later I switched to randomly changing the password and then logging off to lock the desktop, still troublesome. I just never found any good free network administration software; actually, just a black screen would be enough.
The earlier forced logoff scheme had a lot of impractical issues because of shutdown. Its -s forced shutdown can be executed under all users, but if an emergency comes up, even we administrators have no way to cancel it ourselves. And its -l forced logoff likewise can only be executed under the currently logged-in user's account.
This time we use the net user /times parameter to set the hours when a user is allowed to log in
net user onlyit "" /times:monday-friday,8AM-5PM,6PM-10PM;saturday-sunday,8AM-10PM
Permitted login hours Sunday 08:00 AM - 10:00 PM
Monday 08:00 AM - 05:00 PM
Monday 06:00 PM - 10:00 PM
Tuesday 08:00 AM - 05:00 PM
Tuesday 06:00 PM - 10:00 PM
Wednesday 08:00 AM - 05:00 PM
Wednesday 06:00 PM - 10:00 PM
Thursday 08:00 AM - 05:00 PM
Thursday 06:00 PM - 10:00 PM
Friday 08:00 AM - 05:00 PM
Friday 06:00 PM - 10:00 PM
Saturday 08:00 AM - 10:00 PM
This way we have set the specific time periods when the onlyit user can log in each day. For example, on Monday, the user can log in during class hours from 08:00-17:00. Then as long as the user does not log off, students can still use the computer normally after 17:00, so we need to run a scheduled task at 17:15
Lock_workstation.cmd locks the console. During 17:00-18:00 the user will be unable to log in, so this will cause the user to be unable to log in
SCHTASKS /delete /tn Lock_workstation /f
SCHTASKS /create /RU "" /RP onlyedu /SC MINUTE /MO 1 /TN Lock_workstation /TR "%windir%\System32\rundll32.exe user32.dll,LockWorkStation" /ST 17:15:00 /SD 2000/01/01
Compared with the earlier shutdown –l plan, the better point here is that in this state we can keep the students' work, but for unlocking we still need psexec to remotely change the time.
Reference document
Cleverly using the net user command to restrict users from logging into the computer
Lock_workstation.cmd
SCHTASKS /delete /tn Lock_workstation /f
SCHTASKS /create /RU "" /RP onlyedu /SC MINUTE /MO 1 /TN Lock_workstation /TR "%windir%\System32\rundll32.exe user32.dll,LockWorkStation" /ST 17:15:00 /SD 2000/01/01