Jump to content
Sign in to follow this  
eaglekaiser

Local admin name

Recommended Posts

eaglekaiser

Hallo,

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:

Thanks

Share this post


Link to post
Share on other sites
Nova

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
  Exit
EndIf

$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")
   Else
      MsgBox(0, "Info", "Username is Administrateur")
   EndIf  
Else
  MsgBox(0, "Info", "Username is Administrator")     
EndIf

FileDelete('c:\temp.txt')
Exit 0
Edited by Nova

Share this post


Link to post
Share on other sites
Nova

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")
EndIf

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....)

Enjoy

Nova

Edited by Nova

Share this post


Link to post
Share on other sites
eaglekaiser

Thanks guys for the good tips. Indeed, as quick as possible we are going to change the names of the local admin on the workstations so that's always 'Administrator'. For now, your solutions can help me a lot.

Many thanks,

EagleKaiser :idiot:

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.