Jump to content

Recommended Posts


In the LAN of my company, I have to manage the system with 500 workstation PC, connected to a Windows 2003 domain.

The name of the Local Administrator Account on some workstations is 'Administrator'. For some other workstations, that name is fixed as 'Administrateur'.

I have created an automatic update system for the software on the workstations (updates provided by the server) and for some of these upgrades I use the RunAsSet function to log temporarily as Local Admin. The username and password of that Local Admin is included in my compiled AutoIt updatescript.

Problem is: Before I initialise the Local Admin username and password in that script, how can I detect the correct name of the local administrator (administrator of administrateur) ?

Can anyone help me with this ? :idiot:


Link to post
Share on other sites

How about doing a net users command and send the results to a text file ?

Then search the text file for both keywords Administrator and Administrateur

If I were you I would first figure out a way of renaming all accounts so that their all spelt Administrator.

It would save you time in the future.

Edit :Added example code

RunWait(@ComSpec & " /c " & 'net users >> C:/Temp.txt', "", @SW_HIDE)
$file = FileRead("C:/Temp.txt", FileGetSize("C:/Temp.txt"))

If @error Then

$Find1 = StringInStr( $file, "Administrator" ) 
$Find2 = StringInStr( $file, "Administrateur" ) 

If $Find1 = 0 Then
   If $Find2 = 0 Then
      MsgBox(0, "Info", "Username is neither Administrator nor Administrateur")
      MsgBox(0, "Info", "Username is Administrateur")
  MsgBox(0, "Info", "Username is Administrator")     

Exit 0
Edited by Nova
Link to post
Share on other sites

Actually heres a much better idea, it just dawned on me.

Ive havent tested this but it should solve your problem.

Opt("RunErrorsFatal", 1)

RunAsSet("Administrator", @Computername, "adminpassword")

;Use the run command to try run any program of your choice here

If @error Then
   RunAsSet("Administrateur", @Computername, "adminpassword")

Edit: In case its not painfully obvious, the above code trys to run a program using the username Administrator and if the run command returns an error then it trys to use the username Administrateur.

From help file

(If the login information was invalid, subsequent Run/RunWait commands will fail....)



Edited by Nova
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...