eaglekaiser Posted January 8, 2005 Share Posted January 8, 2005 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 ? Thanks Link to comment Share on other sites More sharing options...
Nova Posted January 8, 2005 Share Posted January 8, 2005 (edited) 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 AdministrateurIf 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 codeRunWait(@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 January 8, 2005 by Nova Link to comment Share on other sites More sharing options...
Nova Posted January 8, 2005 Share Posted January 8, 2005 (edited) 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") EndIfEdit: 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....)EnjoyNova Edited January 8, 2005 by Nova Link to comment Share on other sites More sharing options...
eaglekaiser Posted January 8, 2005 Author Share Posted January 8, 2005 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now