Jump to content

Script to Remotely Login to Multiple Computers


chuiting
 Share

Recommended Posts

We currently use a AutoIt script to VNC into remote computers and login.  This is allows us to login to a lab of 30 computers in a few minutes rather than having to do it manually.  

Our script works fine now for logging into all the computers with the same username and password.

Our hope was to expand this script to login with usernames and passwords that were in a text file so that every computer had a different user.

So it would log into computers that were pulled from a text file and use the username and passwords from a text file.  It could use the same text file or separate ones. 

Any help would be greatly appreciated.

Link to comment
Share on other sites

; AutoIt Version: 3.0
; Language: English
;
; Special thanks to Nekkutta from AutoItForums
;
; Script Function:
; Opens VNC, logs into entire lab of computers
;


$PWD = InputBox("Little Chute School District","Please Enter the Admin Password for Access","","*") ; This creates an input box in which the person will type the 'password'
If Not Verify($PWD) Then ; This will call the Verify function (at the bottom) to make sure the password is correct
MsgBox(16,"LCASD","Sorry, wrong password!") ; If it isnt correct a messagebox will popup saying WRONG PASSWORD
Exit ; and then exit
EndIf
; Note if the password is right nothing will be done


Func Verify($PWD) ; the verify function
If $PWD == "Password" Then ; checks if the password they inputted is = the real password (case sensitive)
Return 1 ; if it is correct it will return one
Else
Return 0; if its not correct it will return 0
EndIf
EndFunc

; Prompt the user to run the script - use a Yes/No prompt
$answer = MsgBox(4, "Little Chute Area School Distrct AutoIt v3 Script", "Please make sure all computers are at the login screen. Select Yes when you're ready to select a lab")
; Check the user's answer to the prompt
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
MsgBox(0, "D'oh!", "Please try again when you're ready")
Exit
EndIf
$asCompList = GetCompList(FileOpenDialog("Select File", "", "All Files (*.*)"))
For $i In $asCompList
If $i = "" Then ContinueLoop
Run("vncviewer.exe")

; Wait for the VNC to become active - it is titled "VNC Viewer : Connection Details"
WinWaitActive("VNC Viewer : Connection Details")

; Now that the VNC window is active type the computer name
Send($i & "{ENTER}")




; Wait for the VNC password prompt to become active - it is titled "VNC Viewer : Authentication [No Encryption]"
WinWaitActive("VNC Viewer : Authentication [No Encryption]")

; Type in VNC password
Send("Password")
Send("{ENTER}")

; Wait for the VNC Remote Window to Open "
;WinWaitActive($i)
    ;WinActivate("Log On")
    Sleep(500)
Send("{ENTER}")
    Sleep(1500)
Send("Username")
Send("{TAB}")
Send("Password")
Send("{ENTER}")
    Sleep(500)
Next


Func GetCompList($sFilename)
;Format is file with one computer name per line
;will return a 0 based array for use in a "For $element in $array" loop
$sRawData = FileRead($sFilename)
Return StringSplit($sRawData, @CRLF, 3)
EndFunc ;==>GetCompList

Link to comment
Share on other sites

  • Moderators

chuiting, did you post your script to show the solution, or are you still having an issue? Can you please detail what the problem is, if there is in fact still an issue?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I never like the idea of putting a password in a text file, so I will advise you to at lease add a function to encrypt and decrypt the login password.  To get you started the easy way to keep a record of the user name and password will be using an ini file format example:

[Computer Name1]

UserName = Login Name

Password = Password

[Computer Name2]

UserName = Login Name

Password = Password

 Now that you have your ini file with all the lab's computers, username and password you can replace GetCompList function for IniReadSectionName which return an array of all section names or in your case the computer names.  Also add to the for loop an IniRead to get the username and password values needed for the VNC. 

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
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...