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-24 14:02
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Want to compile a batch script that, at a certain time in XP, prevents access to the system? View 2,281 Replies 13
Original Poster Posted 2006-08-17 22:47 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Want to compile a batch processing, at a certain time in xp, unable to enter the system?
Then, put it in the group policy, windows settings, scripts, startup inside?
I don't know, can anyone help compile it.?
Floor 2 Posted 2006-08-18 01:48 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
The landlord has malicious intentions. Who does he want to harm?
Floor 3 Posted 2006-08-18 08:02 ·  中国 山东 菏泽 电信
银牌会员
★★★
Credits 1,246
Posts 488
Joined 2003-11-11 00:00
22-year member
UID 12699
Gender Male
Status Offline
Originally posted by chainliq at 2006-8-18 01:48 AM:
The poster has evil intentions. Who are you trying to harm?


Think more optimistically:
Maybe trying to restrict children who are studying!
Floor 4 Posted 2006-08-18 09:15 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
If you want to be unable to enter the system at a certain point in time (such as 12:30), you can use "at 12:30 shutdown -s"; but it feels meaningless like this;

If you want to be unable to enter the system during a certain time period (such as between 8:00 and 10:30), you can put the following script into the startup to start with the computer

@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:" %%i in ('time /t') do (
set hour=x%%i& set minute=x%%j
set hour=!hour:~-2!& set minute=!minute:~-2!
set now=!hour!!minute!
if !now! gtr 800 if !now! lss 1030 shutdown -s
)


Later, when testing, a small problem was found, that is, the & after set should be closely followed by the previous sentence, and no space should be left, otherwise, it will cause judgment errors.

[ Last edited by namejm on 2006-8-18 at 13:37 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2006-08-18 10:28 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Thanks to the friend in the previous post.
I'm a newbie. Could you explain the batch file above and note what each line does?
Floor 6 Posted 2006-08-18 14:12 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
In Start/Run, enter

hh ntcmds.chm::/net_user.htm


You can take a look at this


Net user adds or modifies user accounts or displays user account information.

Syntax
net user ]

net user ]

net user ]

Parameters
UserName
Specifies the user account name to add, delete, modify, or view. The user account name can have up to 20 characters.
Password
Assigns or changes the password for the user account. Enter an asterisk (*) to generate a password prompt. The password is not displayed when typing at the password prompt line.
/domain
Performs the operation on the primary domain controller of the computer's primary domain.
options
Specifies command-line options. The following table lists the valid command-line options that can be used. Command-line option syntax Description
/active:{no | yes} Enables or disables the user account. If the user account is inactive, the user cannot access resources in the computer. The default setting is yes (that is, active).
/comment:"text" Provides a descriptive description of the user account. This comment can have up to 48 characters. Enclose the text in quotes.
/countrycode:nnn Uses the operating system "country/region" code to implement the specified language file for user help and error messages. The value 0 represents the default "country/region" code.
/expires:{{mm/dd/yyyy | dd/mm/yyyy | mmm,dd ,yyyy} | never} Expires the user account according to the specified date. The expiration date can be in , or format. It depends on the country/region code. Note that the account expires at the start of the specified date. For the month value, you can use numbers, full names, or three-letter abbreviations (that is, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec). For the year value, you can use two-digit or four-digit numbers. Use commas and slashes to separate the parts of the date. Do not use spaces. If yyyy is omitted, the next occurrence date (depending on the computer's date and time) will be assumed. For example, if the entered date is between January 10, 1994 and January 8, 1995, the following date items are equal:
jan,9
1/9/95
january,9,1995
1/9

/fullname:"name" Specifies the full name of the user instead of the user name. Enclose the name in quotes.
/homedir:Path Sets the path of the user's home directory. This path must exist.
/passwordchg:{yes | no} Specifies whether the user can change their own password. The default setting is yes.
/passwordreq:{yes | no} Specifies whether the user account must have a password. The default setting is yes.
/profilepath: Sets the path of the user's login profile. This path points to the registry profile.
/scriptpath:Path Sets the path of the user's login script. Path cannot be an absolute path. Path is a relative path of %systemroot%\System32\Repl\Import\Scripts.
/times:{day] ,time]

| *} Lists up to 8 workstations where the user can log in to the network. Separate multiple items in the list with commas. If there is no list for /workstations or the list is an asterisk *, the user can log in from any computer.

net help command
Displays help for the specified net command.
Remarks
If used without parameters, net user will display a list of user accounts on the computer. You can also type net users.
The password must meet the minimum length requirement set in net accounts /minpwlen. It can have up to 127 characters. However, if the computer running Windows 2000 or Windows XP is on a network with other computers running Windows 95 or Windows 98, please consider using a password of no more than 14 characters. Windows 95 and Windows 98 support passwords of up to 14 characters. If the password is too long, it may not be possible to log in to the network from those computers.
Examples
To display a list of all user accounts on the local computer, type:

net user

To view information about the user account jimmyh, type:

net user jimmyh


To add a user account for Jay Jamison, with login permissions from 8:00 AM to 5:00 PM from Monday to Friday (no intervals in the time specification), and using a forced password (jayj) and full user name, type:

net user jayj /add /passwordreq:yes /times:monday-friday,8am-5pm/fullname:"Jay Jamison"

To set the login time for johnsw using 24-hour time notation (8:00 AM to 5:00 PM), type:

net user johnsw /time:M-F,08:00-17:00

To set the login time for johnsw using 12-hour time notation (8:00 AM to 5:00 PM), type:

net user johnsw /time:M-F,8am-5pm

To specify the login time for marysl as 4:00 AM to 5:00 PM on Monday, 1:00 PM to 3:00 PM on Tuesday, and 8:00 AM to 5:00 PM from Wednesday to Friday, type:

net user marysl /time:M,4am-5pm;T,1pm-3pm;W-F,8:00-17:00



——Excerpted from "Command Line Reference"

[ Last edited by electronixtar on 2006-8-18 at 14:22 ]

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 7 Posted 2006-08-18 14:27 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Such a good command can be found, electronixtar is really powerful. Hey, I just can't settle down to read ntcmds.chm carefully, so I can only always struggle with those old - fashioned commands there - I really should read htcmds.chm carefully.

After a rough look at the help, I found that the net user command can only limit the whole - hour time, and it can't set times like 12:30, 13:15, which is a pity.

[ Last edited by namejm on 2006 - 8 - 18 at 14:36 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 8 Posted 2006-08-18 19:48 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Originally posted by electronixtar at 2006-8-18 14:12:
In Start/Run, enter

hh ntcmds.chm::/net_user.htm


You can take a look at this



——Excerpted from "Command Line Reference"

[ Last edited by electronixtar on 2006-8-18 ...




Is this batch file placed in Start, Programs, Startup? If so, then the restricted user has already logged in
Floor 9 Posted 2006-08-18 19:57 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Speechless~

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 10 Posted 2006-08-18 20:06 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Originally posted by electronixtar at 2006-8-18 14:12:
In Start/Run, enter

hh ntcmds.chm::/net_user.htm


You can take a look at this



——Excerpted from "Command Line Reference"

[ Last edited by electronixtar on 2006-8-18 ...



After executing the command `net user johnsw /time:M-F,8am-5pm`, does it need to rewrite the registry of the johnsw user?
Is the way to解除 it like this:
`net user johnsw /time:all`, or `net user johnsw /time |all`
I think the format I mentioned above is definitely not correct, right?
Floor 11 Posted 2006-08-18 20:30 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Originally posted by electronixtar at 2006-8-18 19:57:
Speechless~




I'm sorry, I'm a newbie.
Does the net command should revert related registry?
Floor 12 Posted 2006-08-18 23:50 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
net user /time directly associates with the account, takes effect immediately, heh, no need to set up auto-start items~~ The settings are saved as part of the user profile

[ Last edited by electronixtar on 2006-8-18 at 23:53 ]

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 13 Posted 2006-08-19 09:54 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Ah, I understand. The friend upstairs is really very clever! I admire it.
Floor 14 Posted 2006-08-22 03:50 ·  中国 山西 运城 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline

───────────────── Moderation Record ─────────────────
Performed by: Will Sort
Operation: Move topic: From "DOS Troubleshooting & Problem Discussion (Q&A Room)"
Description: According to the topic content classification, it is more suitable to be posted in this forum area
Punishment: Deduct 6 points of reward points for posting this topic, deduct 2 points of penalty points for title violation
───────────────── Moderation Record ─────────────────
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Forum Jump: