Jump to content

Select Username


Recommended Posts

So I have 30 computers that I have inherited. I need to run a program as the admin, however the person who set all of these computers up gave different usernames to all 30, but used the same password. The first 6 characters are all the same, but the last few change, basically numerically increasing. Is it possible for me to write a script that determines which user account is the administrator? There will only be one.

Thanks for any suggestions.

P.S. these are all non-networked systems with LAN and wireless disabled, with limited user accounts, save the one administrator.

Link to comment
Share on other sites

if you KNOW the usernames... make a file with the names.... or if its numerically increasing use a For To Loop

Link to comment
Share on other sites

List current users on the local machine:

NET USER

There are fancier ways, but the idea is that it is not hard for even a non-admin to get a list of user accounts on the machine.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

List current users on the local machine:

NET USER

There are fancier ways, but the idea is that it is not hard for even a non-admin to get a list of user accounts on the machine.

:D

Thanks for the responses. How do you use "NET USER" I can't seem to find it in the help file?

As far as writing a if loop to numberically increase the user, how would I match the user name for the admin?

Again thanks for the input.

Link to comment
Share on other sites

Thanks for the responses. How do you use "NET USER" I can't seem to find it in the help file?

As far as writing a if loop to numberically increase the user, how would I match the user name for the admin?

Again thanks for the input.

It's a shell command, run it from a command line to see the output.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You could also use WMI. Thanks to Autoit Scriptomatic for this one:

#include<array.au3>
$UserArray = Users()
_ArrayDisplay($UserArray)

Func Users()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        Local $return[1]
        $return[0] = 0
        For $objItem In $colItems
            $return[0] += 1
            ReDim $return[UBound($return) + 1]
            $return[UBound($return) - 1] = $objItem.Name
        Next
        Return $return
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc   ;==>Users
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...