Jump to content

listing user profiles


Recommended Posts

How come this wont work?

$FileList=_FileListToArray("C:\Documents and Settings\","*",2) ;;search this folder for any folders within
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
;_ArrayDisplay($FileList,"$FileList")
For $x = 1 to $FileList[0]
    Switch $FileList[$x]
        Case "LocalService"                         ;; users to ignore
        Case "NetworkService"                         ;; users to ignore
        Case "root"                                 ;; users to ignore
        Case Else                                     ;; process all other users
            MsgBox(1,"","Found: " & $FileList[$x])
    EndSwitch
Next
Link to comment
Share on other sites

Works fine here.... what doesn't work for you?

Well maybe its the rest of my code that it doesnt work with. I need it to list the user accounts that have profiles already created for them (ie. they have been logged into before).

#include <Array.au3>
#Include <File.au3>

; #########################################################################################
; # Progress Bar
; #########################################################################################

ProgressOn ( "Account Creation", "IA Tool Kit" )

$UserName = ("IATester")
$Password = ("Password")

ProgressSet ( 10 )

; #########################################################################################
; # List users on the computer that have profiles created
; #########################################################################################

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
Dim $filter[2] = ["user"]
$objDomain.Filter = $filter

$aaUser = ""

For $aUser In $objDomain
  ;$aaUser = $aaUser & $aUSer.Name & " | " & $aUSer.Description & @LF & @LF
   $aaUser = $aaUser & @CR & $aUSer.Name & ": " & $aUSer.Description & @CR & "__________________________________________________________" & @CR
Next

;Beep(500, 100)
MsgBox(4112, "List of Users", $aaUser)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$FileList=_FileListToArray("C:\Documents and Settings\","*",2) ;;search this folder for any folders within
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
;_ArrayDisplay($FileList,"$FileList")
For $x = 1 to $FileList[0]
    Switch $FileList[$x]
        Case "LocalService"                         ;; users to ignore
        Case "NetworkService"                         ;; users to ignore
        Case "root"                                 ;; users to ignore
        Case Else                                     ;; process all other users
            MsgBox(1,"","Found: " & $FileList[$x])
    EndSwitch
Next

;COM Error function
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        ConsoleWrite($oMyError.scriptline & '  $HexNumber = ' & $HexNumber & "Windescription is: " & $oMyError.description & "|" & $oMyError.windescription  & @lf);### Debug Console
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc ;==>ComError

ProgressSet ( 30 )

; #########################################################################################
; # Create IATester account
; #########################################################################################

    $strComputer = @ComputerName
    $colAccounts = ObjGet("WinNT://" & $strComputer & "")
    $objUser = $colAccounts.Create("user", $UserName)
    $objUser.SetPassword ($Password)
    $objUser.Put ("Fullname", "IATester")
    $objUser.Put ("Description", "IA Testing Account")
    $objUser.SetInfo

ProgressSet ( 70 )

; ########################################################################################
; # Add IATester to Administrator and Auditors
; ########################################################################################

$objGroup = ObjGet("WinNT://" & $strComputer & "/Administrators")
$objGroup.Add("WinNT://"&$UserName)

$objGroup = ObjGet("WinNT://" & $strComputer & "/Auditors")
$objGroup.Add("WinNT://"&$UserName)

ProgressSet ( 100 )

; ########################################################################################
; # Force logout
; ########################################################################################

;shutdown (0)
Link to comment
Share on other sites

  • Developers

before even starting to look at the code:

What part works for you and what doesn't work?

EDIT: Guess your issue is that your MSGBOX is located behind the progress window.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...