Jump to content
Sign in to follow this  
HumperHard

listing user profiles

Recommended Posts

HumperHard

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

Share this post


Link to post
Share on other sites
Danny35d

It work in my computer windows xp pro sp3. The only thing I added at the begging was #include <File.au3>


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites
HumperHard

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)

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
HumperHard

before even starting to look at the code:

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

The only part that doesnt work it displaying the profiles..... if I take that piece out it works fine.

Share this post


Link to post
Share on other sites
HumperHard

check my edit of the previous post :P

LOL... how do I change that msgbox to pop up some where else?

edit: nevermind.. I know how to fix...... thanks

Edited by HumperHard

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.