Sign in to follow this  
Followers 0
Guest arthitchinnachot

How To Use Autoit Execute At Remote Computer If ..

5 posts in this topic

How to use Autoit execute at remote computer if I know the administrator password? I mean has any functions in Autoit to do such this.

Thanks in advanced.

arthitchinnachot

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

When you want to just run programs in admin mode you can: (this is from the Helpfile)

Example

; Set the RunAs parameters to use local adminstrator account
RunAsSet("Administrator", @Computername, "adminpassword")

; Run registry editor as admin
RunWait("regedit.exe")

; Reset user's permissions
RunAsSet()

When you need to do other stuff in the script you can restart the script in admin credentials (Larry posted this idea a while ago):

$Username = "administrator"
$Password = "xyz"
$Run = 0
; retrieve the STEP from commandline
If $CmdLine[0] = 1 then $run = $CmdLine[1]
;
If $run = 0 then
   If Not isadmin() Then
    RunAsSet ($Username, @Computername, $Password)
    ; start the script program (itself) again but now in Adminmode...so all tasks will run in Adminmode
      Run('"' & @ScriptFullPath & '" " 1"' ) 
      If @error = 1 Then
         msgbox(48,"Error","cannot start the installation because we are unable to change to adminmode.")    
      EndIf
      Exit
   EndIf
EndIf

: stuff you want to do in admin mode
;
Edited by JdeB

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

Share this post


Link to post
Share on other sites

Thanks so much, JdeB.

How can I apply this script to run more computers(200-500 client computers) in the same time,these computer have the same password?

My idea is use computer name as variable get computer name from text file, how?

Could you please guide me some?

Thanks,

arthitchinnachot

Share this post


Link to post
Share on other sites

Don't these pc's have the same buildin Administrator account that you could use ?

To retrieve the computername you can use the macro: @ComputerName


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I think i misunderstood you after reading it again...

if you want to store the passwords per computer in a file and read it you could do something like the below (Didn't test it so might contain errors)

You can also put them in a Array in the program ... would be saver i think...

; content of info.txt :  computername,psw
;

$fh1=fileopen("info.txt",0)
If $fh1 = -1 Then
     MsgBox(0, "Error", "Unable to open file:")
     Exit
EndIf
while 1
   $line = FileReadLine($fh1)
   If @error = -1 Then 
      msgbox(0,"error". " password not found")
      Exit
   endif
   $u_Info = Stringsplit( $line,",")  
   if $u_Info[0] = @computername then 
      $Password = $u_Info[1] 
      exitloop
   EndIf
Wend

Fileclose($fh1)
; Set the RunAs parameters to use local adminstrator account
RunAsSet("Administrator", @Computername, $password)
; Run registry editor as admin
RunWait("regedit.exe")
; Reset user's permissions
RunAsSet()
Edited by JdeB

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

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  
Followers 0