中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-08 21:12
47,811 topics / 349,895 posts / today 0 new / 48,253 members
DOS学习入门 & 精彩文章 (教学室) » How to restrict a system user's login time in DOS?
Printable Version  2,107 / 10
Floor1 baty812 Posted 2007-05-28 15:49
新手上路 Posts 4 Credits 11
In XP, how can I use the command prompt to restrict a user's login time?
For example, if I want to restrict a user world so that they can only log in from 8 o'clock every day until 0:00 at night, how should I do it??

Also, in DOS
how is the date represented??
For example Monday, Tuesday-------------------------------Sunday
month
and so on!! Thanks!!
Floor2 lxmxn Posted 2007-05-28 21:07
版主 Posts 4,938 Credits 11,386
How should I restrict a user world so that they can only log in from 8 o'clock every day until 0:00 at night??


Administrator privileges are required.

Also, in DOS
how is the date represented??
For example Monday, Tuesday-------------------------------Sunday
month

Enter at the command line:
Floor3 huyingbin Posted 2007-05-29 14:32
初级用户 Posts 12 Credits 23
Does this command work for domain users?
Floor4 baty812 Posted 2007-05-31 10:18
新手上路 Posts 4 Credits 11
Thanks to the moderator for the answer, but how do I remove the restriction?? How do I do that???
Floor5 baty812 Posted 2007-05-31 10:23
新手上路 Posts 4 Credits 11
Then if I want to restrict user world so they can only log in from 8 in the morning until 1 after midnight every day, how is that written??

net user world /times:M-Su,8:00-1:00 ?? No need to add AM or PM??
Floor6 lvbsl Posted 2007-06-08 00:19
初级用户 Posts 15 Credits 30
net user world /times:M-Su,8:00-1:00

For this command, first M-SU means Monday through Sunday, that is, every day

8:00-1:00

This is the 24-hour way of writing it, in this command

it means Sunday 8 in the morning --- Monday 1 in the morning

Monday 8 in the morning --- Tuesday 1 in the morning

Tuesday 8 in the morning --- ....................... that is to say, every day from 8 in the morning until 1 after midnight

No need to add AM and PM. If you add them, the meaning becomes from 8 in the morning to 1 in the afternoon every day


You can also use the 12-hour way of writing it

net user world /times:m-su,8am-1am

This is equivalent to the command above
Floor7 lvbsl Posted 2007-06-08 00:23
初级用户 Posts 15 Credits 30
Originally posted by baty812 at 2007-5-31 10:18 AM:
Thanks to the moderator for the answer, but how do I remove the restriction?? How do I do that???


The command to remove it is net user world /times:all, which means it can log in at any time

The command for never being able to log in

net user world /times:

If it is left blank, that means it can never log in
Floor8 ly2006 Posted 2007-06-09 10:43
新手上路 Posts 7 Credits 2
Learning
Floor9 BWSkyer Posted 2007-06-10 18:47
中级用户 Posts 180 Credits 367 From 重庆
Originally posted by lvbsl at 00:19:
net user world /times:M-Su,8:00-1:00

For this command, first M-SU means Monday through Sunday, that is, every day

8:00-1:00

This is the 24-hour way of writing it, in this command

it means Sunday ...


Hehe, learned something. I didn't expect you could use DOS to restrict a user's login time, awesome!
Floor10 lvbsl Posted 2007-06-11 00:03
初级用户 Posts 15 Credits 30
Yeah, DOS is very powerful
still learning ````
Floor11 dato Posted 2008-05-25 23:08
高级用户 Posts 377 Credits 916
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
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023