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-09-24 17:21
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Statistical user group information View 3,580 Replies 51
Floor 46 Posted 2007-02-10 07:49 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Try again step by step.

I need to go home. The following examples are for your reference.

@echo off
echo All user account IDs are:
echo.
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="The command completed successfully." echo %%i
if not "%%j"=="" echo %%j
if not "%%k"=="" echo %%k
)
echo.
echo The current user account ID is: %username%
pause>nul


Show progress bar.bat
@echo off
:: code by jm 2006-11-30 CMD@XP
set var=">"
set/p=Loading: <nul
ping -n 2 127.1>nul
for /l %%i in (1,1,20) do (
set/p=%var%<nul
ping -n 2 127.1>nul
)
echo.
echo.
pause
Floor 47 Posted 2007-02-10 08:29 ·  中国 北京 联通
初级用户
Credits 52
Posts 25
Joined 2007-02-10 03:18
19-year member
UID 79113
Gender Male
Status Offline
According to your method, it can display the user, but the user's information still hasn't been displayed.
Floor 48 Posted 2007-02-10 22:05 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="命令成功完成。" echo %%i >>1.txt
if not "%%j"=="" echo %%j >>1.txt
if not "%%k"=="" echo %%k >>1.txt
)
for /f %%a in (1.txt) do net user %%a | find "Username"
::for /f %%a in (1.txt) do net user %%a | find "Local group members"
::for /f %%a in (1.txt) do net user %%a | find "Global group members"

[ Last edited by qingfushuan on 2007-2-10 at 09:53 AM ]
Floor 49 Posted 2007-02-10 22:15 ·  中国 北京 歌华宽带
初级用户
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-10 09:05 AM:
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="命令成功完成。" echo %%i >>1.txt
if not "%%j"=="" echo %% ...

The result of this script execution
__vmware_user__
Administrator
Guest
HelpAssistant
SUPPORT_388945a0
hasn't counted the group information of the users yet, brother, take another look?
Floor 50 Posted 2007-02-10 23:00 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
@echo off
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="命令成功完成。" echo %%i >>1.txt
if not "%%j"=="" echo %%j >>1.txt
if not "%%k"=="" echo %%k >>1.txt
)
for /f %%a in (1.txt) do net user %%a | find "Username"&net user %%a | find "Local Group Members"&net user %%a | find "Global Group Members"

[ Last edited by qingfushuan on 2007-2-10 at 10:07 AM ]
Floor 51 Posted 2007-02-10 23:38 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
@echo off
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="命令成功完成。" echo %%i %%j %%k >>1.txt
)
for /f %%a in (1.txt) do net user %%a|findstr /r "用户名 本地组成员 全局组成员"

I'm a newbie learning while answering your question, sorry about that. Can the above be further simplified? I think it should be possible without generating 1.txt?

[ Last edited by qingfushuan on 2007-2-10 at 11:28 AM ]
Floor 52 Posted 2007-02-10 23:43 ·  中国 江苏 连云港 电信
高级用户
★★★
前进者
Credits 641
Posts 303
Joined 2007-01-10 02:57
19-year member
UID 76009
Gender Male
Status Offline
%username% always refers to one user, and it won't list all users. Directly using net user will list all usernames, and using echo %username% is the username of the user who is currently logged in to the computer.
我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿!
Forum Jump: