Home > Software engineering >  How to list all local users in the above applies, and the group and the corresponding user below
How to list all local users in the above applies, and the group and the corresponding user below

Time:10-03

As title, using VB to
I want to winows2003 system, all local users and groups in the
The user, all listed, write database,
And all the groups, and groups of users, also want to record,

consult

CodePudding user response:

What made, there is a library for you,
Forget, when we get a lot of information,
The code also don't know what the lost,

CodePudding user response:

 
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

The Public Function GetAllUser ()
StrComputer=". "the 'computer name,. For the native
StrNameSpace="root \ cimv2" 'specified namespace for root \ cimv2
StrClass="Win32_UserAccount" 'designated class as Win32_Service
Set objSWbemLocator=CreateObject (" WbemScripting. SWbemLocator ") 'build a WBEM object reference pointer
Set objSWbemServices=objSWbemLocator. ConnectServer (strComputer strNameSpace) 'to connect to the specified computer, WMI namespace, return a reference to SWbemServices object
Dim As Long I
Dim tmpu As String
The Set objSWbemObjectSet=objSWbemServices. ExecQuery (" SELECT * FROM "& amp; StrClass) 'by WQL query, return all of the specified class
For Each objSWbemObject objSWbemObjectSet In
With objSWbemObject
Tmpu=IIf (tmpu="", the Name, tmpu & amp; ";" & .name)
'the Debug. Print. AccountType & amp; . Installdate & amp; .name & amp; "-" & amp; . PasswordChangeable & amp; . The Status & amp; The Domain & amp; . SIDType & amp; "Ha ha" & amp; . PasswordRequired & amp; . SID & amp; . PasswordExpires & amp; . The Description
End With
Next
GetAllUser=tmpu
End the Function


CodePudding user response:

 strComputer=". "
'strOutputFilePath="\ \ server \ sharefolder "

The Set objNetwork=CreateObject (" work "Wscript.Net
The Set objFSO=CreateObject (" Scripting. FileSystemObject ")
The Set objfil=objfso. CreateTextFile (strOutputFilePath & amp; Objnetwork.Com puterName & amp; ". TXT ", True)

The Set colGroups=GetObject (" WinNT://"& amp; StrComputer & amp; "")
ColGroups. Filter=Array (" group ")
For Each objGroup colGroups In
Objfil. WriteLine "Group:" & amp; ObjGroup. Name
For Each objUser in objGroup. Members
Objfil. WriteLine vbTab & amp; ObjUser. Name
Next
Next
Objfil. Close


http://bbs.winos.cn/thread-20965-1-1.html
  • Related