代码如下:
Set objGroup = GetObject("WinNT://./administrators")
For each objMember in objGroup.Members
Wscript.Echo objMember.class & "=" & objMember.Name
Next
显示结果是这样的:
user=administrator
user=john_xia(这个是域用户)
但是我想要的结果是:
user=administrator
user=域名/john_xia
就跟net localgroup administrators 的结果一样的。
要怎么实现呢,因为本机用户跟域用户的用户名可能相同,所以要把域名给显示出来。
用vbs列出管理员组成员
答案:2 悬赏:0 手机版
解决时间 2021-01-28 23:03
- 提问者网友:泪痣哥哥
- 2021-01-28 14:25
最佳答案
- 五星知识达人网友:不如潦草
- 2021-01-28 15:48
------------------------VBS团队-------------------------
Set objGroup = GetObject("WinNT://./administrators")
For each objMember in objGroup.Members
'Wscript.Echo objMember.class & "=" & objMember.Name
Set matches = GetObject("winmgmts:").execquery("select * from win32_UserAccount where name ='"&objMember.Name&"'")
For Each match In matches
If match.domain <>"" Then
WScript.Echo objMember.class & "=" &match.domain &"/"& objMember.Name
Else
Wscript.Echo objMember.class & "=" & objMember.Name
End If
Next
Next
有问题再沟通。
------------------------VBS团队-------------------------
Set objGroup = GetObject("WinNT://./administrators")
For each objMember in objGroup.Members
'Wscript.Echo objMember.class & "=" & objMember.Name
Set matches = GetObject("winmgmts:").execquery("select * from win32_UserAccount where name ='"&objMember.Name&"'")
For Each match In matches
If match.domain <>"" Then
WScript.Echo objMember.class & "=" &match.domain &"/"& objMember.Name
Else
Wscript.Echo objMember.class & "=" & objMember.Name
End If
Next
Next
有问题再沟通。
------------------------VBS团队-------------------------
全部回答
- 1楼网友:野味小生
- 2021-01-28 16:05
createobject("shell.application").shellexecute "bat文件","","","runas",1
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯