China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 17:27
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » How to restrict a system user's login time in DOS? View 2,010 Replies 10
Original Poster Posted 2007-05-28 15:49 ·  中国 福建 泉州 电信
新手上路
Credits 11
Posts 4
Joined 2007-04-27 11:44
19-year member
UID 86663
Gender Male
Status Offline
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!!
Floor 2 Posted 2007-05-28 21:07 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
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??

net user world /times:M-Su,20:00-24:00

Administrator privileges are required.

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

Enter at the command line:
echo %date% %time%
Floor 3 Posted 2007-05-29 14:32 ·  中国 广东 东莞 博路电信科技公司
初级用户
Credits 23
Posts 12
Joined 2006-09-05 05:40
19-year member
UID 61879
Status Offline
Does this command work for domain users?
Floor 4 Posted 2007-05-31 10:18 ·  中国 福建 泉州 电信
新手上路
Credits 11
Posts 4
Joined 2007-04-27 11:44
19-year member
UID 86663
Gender Male
Status Offline
Thanks to the moderator for the answer, but how do I remove the restriction?? How do I do that???
Floor 5 Posted 2007-05-31 10:23 ·  中国 福建 泉州 电信
新手上路
Credits 11
Posts 4
Joined 2007-04-27 11:44
19-year member
UID 86663
Gender Male
Status Offline
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??
Floor 6 Posted 2007-06-08 00:19 ·  中国 四川 绵阳 电信
初级用户
Credits 30
Posts 15
Joined 2007-06-07 14:22
19-year member
UID 90558
Gender Male
Status Offline
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
Floor 7 Posted 2007-06-08 00:23 ·  中国 四川 绵阳 电信
初级用户
Credits 30
Posts 15
Joined 2007-06-07 14:22
19-year member
UID 90558
Gender Male
Status Offline
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
Floor 8 Posted 2007-06-09 10:43 ·  中国 广东 广州 花都区 电信
新手上路
Credits 2
Posts 7
Joined 2007-06-08 23:04
19-year member
UID 90734
Gender Male
Status Offline
Learning
Floor 9 Posted 2007-06-10 18:47 ·  中国 江苏 苏州 电信
中级用户
★★
我是DOS学者
Credits 367
Posts 180
Joined 2006-05-14 10:53
20-year member
UID 55507
Gender Male
From 重庆
Status Offline
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!
Floor 10 Posted 2007-06-11 00:03 ·  中国 四川 绵阳 电信
初级用户
Credits 30
Posts 15
Joined 2007-06-07 14:22
19-year member
UID 90558
Gender Male
Status Offline
Yeah, DOS is very powerful
still learning ````
Floor 11 Posted 2008-05-25 23:08 ·  中国 上海 杨浦区 电信
高级用户
★★★
Credits 916
Posts 377
Joined 2004-03-08 00:00
22-year member
UID 19523
Gender Male
Status Offline
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
Forum Jump: