![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-29 08:53 |
47,816 topics / 349,916 posts / today 0 new / 48,265 members |
| DOS批处理 & 脚本技术(批处理室) » [Solved] How to extract the group the user belongs to? |
| Printable Version 1,976 / 6 |
| Floor1 muya05 | Posted 2006-12-24 11:15 |
| 初级用户 Posts 22 Credits 58 | |
|
If the user belongs to the administrator group is displayed as administrators;
If the user belongs to the normal user group is displayed as users; I wrote a line of code myself, but it can't run. Which big brother can pick out the mistakes, Or give a new idea is also okay, 3Q! The code is as follows (this code is wrong!): [ Last edited by muya05 on 2006-12-24 at 07:23 PM ] |
|
| Floor2 namejm | Posted 2006-12-24 11:24 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
```
@echo off net user %username%|find /i "*administrators">nul&&echo administrators||echo users pause ``` |
|
| Floor3 muya05 | Posted 2006-12-24 11:47 |
| 初级用户 Posts 22 Credits 58 | |
|
RE namejm brother
3Q It's all my fault for being negligent when asking the question. If there are only two groups, the problem is indeed solved. For multiple groups, the method of the brother also works, but it's a bit troublesome. Looking forward to a better method. All user groups on my system (WIN 2003 SP1): __VMWARE__ Administrators Backup Operators Distributed COM Users Guests HelpServicesGroup Network Configuration Operators Performance Log Users Performance Monitor Users Power Users Print Operators Remote Desktop Users Replicator TelnetClients Users |
|
| Floor4 lxmxn | Posted 2006-12-24 12:18 |
| 版主 Posts 4,938 Credits 11,386 | |
|
###
Execute in the command line to get the group where the currently logged-in user is located. |
|
| Floor5 muya05 | Posted 2006-12-24 22:40 |
| 初级用户 Posts 22 Credits 58 | |
|
RE lxmxn brother
3Q! It would be even better if the " * " (asterisk) could be removed~ |
|
| Floor6 ccwan | Posted 2006-12-24 22:57 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
```for /f "tokens=2 delims=*" %a in ('net user %username%^|find "本地"') do @echo %~a```
|
|
| Floor7 muya05 | Posted 2006-12-25 08:18 |
| 初级用户 Posts 22 Credits 58 | |
|
The problem is solved.
3Q! Really want to know how the experts of the DOS Union become accomplished~~? Salute! [ Last edited by muya05 on 2006-12-24 at 07:24 PM ] |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |