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 10:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Statistical user group information View 2,997 Replies 51
Floor 16 Posted 2007-02-10 05:24 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by yuipr at 2007-2-9 04:16 PM:

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 ...

The word "local" means that it is supposed to query the user group information of the local machine. I don't know if I wrote this wrong. It can be changed to any host name. Oh, expert, help me. I need the result today.

[ Last edited by yuipr on 2007-2-9 at 04:27 PM ]
Floor 17 Posted 2007-02-10 05:25 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by ccwan at 2007-2-9 04:21 PM:
Does the output of your net user command contain "local"? I don't have it here. So the code doesn't work for me here.

What are the feasible solutions?
Floor 18 Posted 2007-02-10 05:32 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Floor 19 Posted 2007-02-10 05:36 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
The English state "Local Group Memberships" is "Local Group Memberships"

Under English CMD:
for /f "tokens=2 delims=*" %%a in ('net user %username%^|find "Local Group Memberships"') do @echo %%~a


Under Chinese CMD:
for /f "tokens=2 delims=*" %%a in ('net user %username%^|find "本地组成员"') do @echo %%~a
Floor 20 Posted 2007-02-10 05:36 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
What good suggestions do you have regarding this entire batch processing, and what methods can be used to achieve my requirements?
Floor 21 Posted 2007-02-10 05:45 ·  中国 北京 联通
初级用户
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 04:36 PM:
The English state "Local Group Memberships" is "Local Group Memberships"

In English CMD:
for /f "tokens=2 delims=*" %%a in ('net user %username%^|find "Local Group Memberships&quo ... 

Still not right, strange. Could it be that it can be realized on your machines?
Floor 22 Posted 2007-02-10 05:47 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
C:\Documents and Settings\yichuanj>@echo off for /f "tokens=2 delims=*" %a in ('
net user %username%^ |find "Local Group Memberships"') do @echo %~a
FIND: Parameter format not correct
Floor 23 Posted 2007-02-10 05:59 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Originally posted by yuipr at 2007-2-9 16:47:
C:\Documents and Settings\yichuanj>@echo off for /f "tokens=2 delims=*" %a in ('
net user %username%^ |find "Local Group Memberships"') do @echo %~a
FIND: Parameter format ...


Does the brother always like to run @echo off and the command that should be on the second line together in one line?
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 24 Posted 2007-02-10 06:04 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by redtek at 2007-2-9 04:59 PM:

Does the brother always like to run @echo off and the command that should be on the second line in one line together?

Thanks for the reminder:
C:\Documents and Settings\yichuanj>@echo off
for /f "tokens=2 delims=*" %a in ('net user %username%^|find "Local Group Member
ships"') do @echo %~a
The user name could not be found.

More help is available by typing NET HELPMSG 2221.
There is still a problem,
Floor 25 Posted 2007-02-10 06:05 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
It is suggested that the brother first remove the "for" and debug the "net...." sentence well first.

Then add the "for" back. Otherwise, you won't know how each layer is wrong, which will instead increase the complexity of debugging and solving the problem:)


If the brother hopes to solve the problem in one go, it is suggested as follows:


1、The brother only executes the sentence "net user %username%", and then paste the returned information, for the convenience of debugging.

2、The brother marks out the information you want in the above returned information (marked with colors)

3、After everyone confirms it is correct, then add For and Find to operate. These are just a matter of one step.

[ Last edited by redtek on 2007-2-9 at 05:07 PM ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 26 Posted 2007-02-10 06:12 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Originally posted by redtek at 2007-2-9 05:05 PM:
It is suggested that you first remove the "for" and debug the line "net ...." first.

Then add the "for" back. Otherwise, you won't know where each layer goes wrong, which will only increase the complexity of debugging and problem-solving:)



Thank you very much for your detailed answer.
C:\Documents and Settings\yichuanj>@echo off
net uesr %username%
The syntax of this command is:


NET

I don't know if this debugging method of mine is correct?
Floor 27 Posted 2007-02-10 06:21 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
This is the CMD output under the code page: 437 in English state when switching code pages:
The content displayed by executing the command: net user %username%:



User name abc
Full Name Abc
Comment
User's comment
Country code 000 (System Default)
Account active Yes
Account expires Never

Password last set 5/26/2005 2:26 PM
Password expires Never
Password changeable 5/26/2005 2:26 PM
Password required Yes
User may change password No

Workstations allowed All
Logon script
User profile
Home directory
Last logon 2/9/2007 7:54 AM

Logon hours allowed All

Local Group Memberships *Administrators *Debugger Users
*Remote Desktop Users *Users
Global Group memberships *None
The command completed successfully.




Brother, compare and see what you want to get?



Also: Brother, enter in the command line

CHCP


After entering the above command and pressing Enter, want to see which code page the brother's CMD is defaulting to, and paste the version of the brother's operating system.



This is the input content of executing the command: net user %username% under the Windows CMD Chinese 936 code page:



User name abc
Full Name Abc
Comment
User's comment
Country/Region code 000 (System default)
Account enabled Yes
Account expires Never

Password last set 5/26/2005 2:26 PM
Password expires Never
Password changeable 5/26/2005 2:26 PM
Password required Yes
User may change password No

Workstations allowed All
Logon script
User profile
Home directory
Last logon 2/9/2007 7:54 AM

Allowed logon hours All

Local group memberships *Administrators *Debugger Users
*Remote Desktop Users *Users
Global group memberships *None
The command completed successfully.

    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 28 Posted 2007-02-10 06:26 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Also, I don't have time to debug for you,
Just seeing that you didn't fully state what you need at one go, and you didn't write out the execution effect of single-stepping on your own machine, which is anxious-making,
So, I just wrote the above suggestions :)

If you fully write out these information, Brother zh159 and Brother ccwan can solve this problem for you in one step :)

So, it's suggested that you fully state the problem at one time, so that the solvers can very conveniently solve it at one go :)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 29 Posted 2007-02-10 06:26 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Floor 30 Posted 2007-02-10 06:30 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
Thanks a lot for brother redtek's answer again.
C:\>chcp
Active code page: 936

My operating system is winxp en sp2.
I execute C:\> net user %username% in cmd mode.
The user name could not be found.

More help is available by typing NET HELPMSG 2221.

My code page should be the same as yours. Why do I get the prompt that the user is not found? It seems that the problem is at the step of net user %username%.

[ Last edited by yuipr on 2007-2-9 at 05:33 PM ]
Forum Jump: