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-08-03 09:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Statistical user group information View 2,987 Replies 51
Original Poster Posted 2007-02-10 03:47 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
@echo off
for /f "tokens=2 delims=*" %a in ('net user %username%^|find "local"') do @echo %~a
How to use this command to prompt an error.

[ Last edited by yuipr on 2007-2-9 at 03:21 PM ]
Floor 2 Posted 2007-02-10 04:16 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
In batch processing, use `%%a` (double percent signs), and in the command line, use `%a` (single percent sign)
Floor 3 Posted 2007-02-10 04:21 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Is this the case:
@echo off
for /f "tokens=2 delims=*" %%a in ('net user %username% ^|find "local"') do @echo %~a
Still no good?

[ Last edited by yuipr on 2007-2-9 at 03:23 PM ]
Floor 4 Posted 2007-02-10 04:23 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by zh159 at 2007-2-9 03:16 PM:
In batch processing, use %%a (double percent sign), and in the command line, use %a (single percent sign)

Could you please explain it again? I'm in a hurry.
Floor 5 Posted 2007-02-10 04:27 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
for /f "tokens=2 delims=*" %%a in ('net user %username%^|find "local"') do @echo %%~a

[ Last edited by zh159 on 2007-2-9 at 03:33 PM ]
Floor 6 Posted 2007-02-10 04:33 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by zh159 at 2007-2-9 03:27 PM:
for /f "tokens=2" %%a in ('net user %username%^|find "local"') do @echo %%~a

[ Last edited by zh159 on 2007-2007-2-9 at 03:31 PM ]

Modified according to yours, executed with batch processing, nothing is displayed, no error is seen, so the command execution error is as follows "
C:\>@echo off
for /f "tokens=2 delims=*" %a in ('net user'%username%'^|find"local"') do @echo
%~a
'find"local"' is not recognized as an internal or external command,
operable program or batch file.
Floor 7 Posted 2007-02-10 04:36 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Your 'net user'%username%'^|find"local"' writing is completely wrong, there is no space in the middle.

'net user "%username%"^|find "local"'

[ Last edited by zh159 on 2007-2-9 at 03:37 PM ]
Floor 8 Posted 2007-02-10 04:45 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
According to what you said, it's modified:
C:\Documents and Settings\yichuanj>@echo off for /f "tokens=2 delims=*" %a in ('net user'%username%'^|find "local"') do @echo
off for /f "tokens=2 delims=*" %a in ('net user'yichuanj'|find "local"') do @ech
o
This is what is automatically displayed after the command is executed. The batch processing still doesn't work. Can you write a complete batch processing for user information statistics and send it here? I've been struggling for a day and still can't get it done. I'm really frustrated. Thanks

[ Last edited by yuipr on 2007-2-9 at 03:46 PM ]
Floor 9 Posted 2007-02-10 04:50 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
user'yichuanj'

Let's see if you can spot any issues
Floor 10 Posted 2007-02-10 04:54 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
My system environment is "domain", this user is a user in the domain and also the user I am currently logged in to the local machine with, and I don't see any problems.
Floor 11 Posted 2007-02-10 04:59 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
net user'%username%'

The space between 'user' and '%username%' is missing, and '%username%' should be enclosed in double quotes "" instead of single quotes ''
Floor 12 Posted 2007-02-10 05:10 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
I'm sorry, I made a change.
C:\Documents and Settings\yichuanj>@echo off
for /f "tokens=2 delims=*" %a in ('net user "%username%" ^|find "local"') do @echo %~a
The user name could not be found.

More help is available by typing NET HELPMSG 2221.
Floor 13 Posted 2007-02-10 05:16 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by qingfushuan at 2007-2-9 04:13 PM:
net user %username% is to query the detailed information of the current user,

Looking at your title, it's to query all user information

Try removing %username%

C:\Documents and Settings\yichuanj>@echo off for /f "tokens=2 delims=*" %a in ('net user ^|find "local"') do @echo %~a
off for /f "tokens=2 delims=*" %a in ('net user |find "local"') do @echo %~a
Still not right?
Floor 14 Posted 2007-02-10 05:21 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Does the output of your net user command contain "local"? I don't have it here. So the code doesn't work on my side.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 15 Posted 2007-02-10 05:21 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Execute net user ^| find "local" >>1.txt, 1.txt has no content, which means your sentence is wrong.
Forum Jump: