如何列出 windows2003 中所有本地用户,以及组和对应组下面的用户
如题,用VB我要对winows2003 系统中,所有本地用户和组中
用户,全部列出,写入数据库。
以及所有的组,和组里面的用户,也要记录下来。
请教 --------------------编程问答-------------------- 搞过,有个什么库给你用的。
忘了,当初搞时查了不少资料。
代码也不知道丢哪了。 --------------------编程问答--------------------
Dim objSWbemLocator As SWbemLocator
Dim objSWbemServices As SWbemServices
Dim objSWbemObjectSet As SWbemObjectSet
Dim objSWbemObject As SWbemObject
Dim strComputer As String, strNameSpace As String, strClass As String
Public Function GetAllUser()
strComputer = "." '计算机名,.为本机
strNameSpace = "root\cimv2" '指定命名空间为root\cimv2
strClass = "Win32_UserAccount" '指定类为Win32_Service
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") '建立1个WBEM对象的引用指针
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, strNameSpace) '连接到指定计算机、命名空间的WMI,返回一个对 SWbemServices 对象的引用
Dim i As Long
Dim tmpu As String
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
With objSWbemObject
tmpu = IIf(tmpu = "", .Name, tmpu & ";" & .Name)
' Debug.Print .AccountType & .installdate & .Name & "-" & .PasswordChangeable & .Status & .Domain & .SIDType & "哈哈" & .PasswordRequired & .SID & .PasswordExpires & .Description
End With
Next
GetAllUser = tmpu
End Function
补充:VB , 基础类