|
mayamason
初级用户
 
积分 46
发帖 19
注册 2006-9-28
状态 离线
|
『楼 主』:
关于NET USER 的问题
使用 LLM 解释/回答一下
我想做个BAT去添加本地账号,但是不知道如何在命令行下修改"密码永不过期"的选项.
我的CMD是net user qgp password/add /active:yes /expires:never /passwordchg:no /passw
ordreq:yes
顺便问下如果用IF判断是否存在qgp用户应该如何操作.谢谢了.
I want to make a BAT to add a local account, but I don't know how to modify the "password never expires" option in the command line.
My CMD is net user qgp password/add /active:yes /expires:never /passwordchg:no /passw
ordreq:yes
By the way, how to operate if using IF to judge whether the qgp user exists. Thanks.
|
|
2006-10-9 22:04 |
|
|
mayamason
初级用户
 
积分 46
发帖 19
注册 2006-9-28
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
Netuser is a freeware command line / batch program that will rename a user account.
usage: netuser username <settings>
<settings>:
download from here
http://www.jsifaq.com/dl/netuser.zip
/name:newname
/pwnexp:{y|n} sets Password Never Expires
Examples:
netuser Administrator /name:"My Domain Admin"
netuser "John Doe" /name:DoeJ
Netuser is a freeware command line / batch program that will rename a user account.
usage: netuser username <settings>
<settings>:
download from here
http://www.jsifaq.com/dl/netuser.zip
/name:newname
/pwnexp:{y|n} sets Password Never Expires
Examples:
netuser Administrator /name:"My Domain Admin"
netuser "John Doe" /name:DoeJ
|
|
2006-10-10 00:02 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
1、net user qgp password/add /active:yes /expires:never /passwordchg:no /passwordreq:yes
其中,红色的部分是修改密码永不过期的选项,其值可以是never,也可以指定一个日期,就是到这天就过期了,比如10/10/08。
2、可以用if判断来实现判断是否存在qgp用户是否存在。
@echo off
for /f %%i in ('net user ^| find "qgp"') do (
if not "%%i#"=="#" echo 存在qpg这个用户。& goto :lxm
)
echo 不存在qgp这个用户。
:lxm
pause
但是这个代码有一定的局限行,如果还有一个系统帐户名为qgpabc的用户的话,也会报有这个用户的。
1、net user qgp password/add /active:yes /expires:never /passwordchg:no /passwordreq:yes
Among them, the part in red is the option to modify that the password never expires. Its value can be never, or a specific date can be specified, meaning it expires on that day, such as 10/10/08.
2、You can use an if judgment to implement checking whether the qgp user exists.
@echo off
for /f %%i in ('net user ^| find "qgp"') do (
if not "%%i#"=="#" echo There is the qpg user. & goto :lxm
)
echo The qgp user does not exist.
:lxm
pause
But this code has certain limitations. If there is also a system account named qgpabc, it will also report that this user exists.
|
|
2006-10-10 02:54 |
|
|
weilong888
银牌会员
    
积分 1270
发帖 548
注册 2004-5-31
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
这个for与if的功能确实强大,不多试几下不能理解透切。
The functions of this for and if are really powerful. You can't understand them thoroughly without trying them several more times.
|
|
2006-10-10 06:20 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
判断帐户是否存在的两段代码:
绝对不会出错的代码:
@echo off
net user qgp >nul 2>nul && echo 存在该用户 || echo 用户不存在.
pause
有一定局限性的代码:
@echo off
set trom=1
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="" if not "%%i"=="命令成功完成。" if "%%i"=="qgp" echo 用户存在. & set trom=2
if not "%%j"=="" if "%%j"=="qgp" echo 用户存在. & set trom=2
if not "%%k"=="" if "%%k"=="qgp" echo 用户存在. & set trom=2
)
if "%trom%"=="1" echo 用户不存在.
pause
Two codes to determine if an account exists:
Code that will never go wrong:
@echo off
net user qgp >nul 2>nul && echo The user exists || echo The user does not exist.
pause
Code with certain limitations:
@echo off
set trom=1
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="" if not "%%i"=="The command completed successfully." if "%%i"=="qgp" echo The user exists. & set trom=2
if not "%%j"=="" if "%%j"=="qgp" echo The user exists. & set trom=2
if not "%%k"=="" if "%%k"=="qgp" echo The user exists. & set trom=2
)
if "%trom%"=="1" echo The user does not exist.
pause
|
|
2006-10-10 08:37 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
pengfei兄的思路果然开阔,第一个 代码中的“net user qgp >nul 2>nul”以及“&&”和"||"使用得相当巧妙,而第二个代码也是一种比较新颖的思路~
学习中——————
Brother pengfei's ideas are indeed broad. The "net user qgp >nul 2>nul" in the first code and the use of "&&" and "||" are quite clever, and the second code is also a relatively novel idea~
Learning——————
|
|
2006-10-10 09:22 |
|
|
mayamason
初级用户
 
积分 46
发帖 19
注册 2006-9-28
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by lxmxn at 2006-10-10 02:54:
1、net user qgp password/add /active:yes /expires:never /passwordchg:no /passwordreq:yes
其中,红色的部分是修改密码永不过期的选项,其 ...
更正一下这个EXPIRES是账号的过期时间,而不是密码的过期选项.
Originally posted by lxmxn at 2006-10-10 02:54:
1、net user qgp password/add /active:yes /expires:never /passwordchg:no /passwordreq:yes
Among them, the part in red is the option to set the account to never expire, and its ...
Correct that EXPIRES is the account expiration time, not the password expiration option.
|
|
2006-10-10 19:52 |
|
|
mayamason
初级用户
 
积分 46
发帖 19
注册 2006-9-28
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
pengfei 兄,能解释下你的第一段代码吗?
Brother pengfei, can you explain your first code segment?
|
|
2006-10-10 19:53 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
第一段代码很简单, 就是使用net user来列出用户, 如果用户存在就会执行成功, 反之返回2. 利用这一点就能够非常准确地判断用户是否存在了.
而第二段代码的算法是, 列出所有的用户名, 然后判断用户是否存在. 这里有局限性是因为如果用户名有空格就会提示用户不存在.
The first piece of code is very simple, which is to use net user to list users. If the user exists, it will execute successfully; otherwise, it returns 2. Making use of this, we can very accurately judge whether the user exists.
And the algorithm of the second piece of code is to list all user names and then judge whether the user exists. The limitation here is that if the user name has a space, it will prompt that the user does not exist.
|
|
2006-10-10 23:06 |
|
|
mayamason
初级用户
 
积分 46
发帖 19
注册 2006-9-28
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
pengfei 的解释太经典了
Pengfei's explanation is too classic.
|
|
2006-10-11 00:33 |
|
|
mayamason
初级用户
 
积分 46
发帖 19
注册 2006-9-28
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
@echo off
echo Testing your network...
ping www.google.com -n 2 >nul 2>nul && echo Site1 is online || echo Site1 network down
ping www.go12ogle.com -n 2 >nul 2>nul && echo Site2 is online || echo Site2 network down
Pause
大家可以用这个代码去做测试.
@echo off
echo Testing your network...
ping www.google.com -n 2 >nul 2>nul && echo Site1 is online || echo Site1 network down
ping www.go12ogle.com -n 2 >nul 2>nul && echo Site2 is online || echo Site2 network down
Pause
Everyone can use this code for testing.
|
|
2006-10-12 10:02 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by pengfei at 2006-10-10 23:06:
第一段代码很简单, 就是使用net user来列出用户, 如果用户存在就会执行成功, 反之返回2. 利用这一点就能够非常准确地判断用户是否存在了.
而第二栮..
呵呵,试了一下,不能在CMD下面建立含有空格字符的用户,但是在lusrmgr.msc里面却可以`
看来WIN都做到的事情,在CMD下不一定可以做到哦``
Originally posted by pengfei at 2006-10-10 23:06:
The first piece of code is very simple, which is to use net user to list users. If the user exists, it will execute successfully; otherwise, it returns 2. Using this point, you can very accurately determine whether the user exists.
And the second...
Hehe, I tried it. I can't create a user with a space character in CMD, but I can in lusrmgr.msc.
It seems that what Windows can do is not necessarily achievable in CMD.``
|
|
2006-10-14 02:43 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
用户名和用户全称是不一样的
The user name and the full user name are different.
|

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'>" |
|
2006-10-14 02:44 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
Originally posted by lxmxn at 2006-10-14 02:43:
呵呵,试了一下,不能在CMD下面建立含有空格字符的用户,但是在lusrmgr.msc里面却可以`
看来WIN都做到的事情,在CMD丠...
不能建立空格的吗? “”
Originally posted by lxmxn at 2006-10-14 02:43:
Hehe, I tried it. I can't create a user with a space character under CMD, but I can do it in lusrmgr.msc.
It seems that what WIN can do, under CMD... Can't create one with spaces? “”
|
|
2006-10-14 04:13 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
RE:he200377
呵呵,多谢提醒,忘记还可以用引号括起来了,看来我还没有做足够多的测试。
RE: he200377
Hehe, thanks for the reminder, forgot that it can also be enclosed in quotes. It seems I haven't done enough testing.
|
|
2006-10-14 12:47 |
|