我写了一个实现了半成方法,不知道会不会比较快,但是支持用户密码。这个缺点是只能列出“用户名+用户组”(没有分开的)和“用户名”,效果自己看:- Dim strComputer,strUsername,strPassword
- Dim colSWbemObjectSet,objSWbemObject,strOut
-
- strComputer = "计算机名"
- strUsername = "用户名" '没有就留空
- strPassword = "密码" '没有就留空
-
- Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
- Set objSWbemServices = objSWbemLocator.ConnectServer _
- (strComputer, "root\cimv2", strUsername, strPassword)
- Set colSWbemObjectSet = objSWbemServices.ExecQuery( _
- "SELECT * FROM Win32_Account",,48)
-
- strOut = "用户名+用户组:" & vbCrLf
- For Each objSWbemObject In colSWbemObjectSet
- strOut = strOut & objSWbemObject.Name & vbCrLf
- Next
-
- WScript.Echo strOut
-
- strOut = "用户组:" & vbCrLf
-
- Set colSWbemObjectSet = objSWbemServices.ExecQuery( _
- "SELECT * FROM Win32_Group",,48)
-
- For Each objSWbemObject In colSWbemObjectSet
- strOut = strOut & objSWbemObject.Name & vbCrLf
- Next
-
- WScript.Echo strOut
-
复制代码 要完全实现可能就得用那个效率不高的方法了 |