Jump to content

Local login remotely with AutoIT?


Recommended Posts

I am trying to log into several computers in a classroom lab all at once. This will save time for the teacher when dealing with younger children.

Basically, I have TightVNCServer running on each machine. I use an AutoIT script (compiled to .exe) to parse a CSV file to get the machine name, username, and password. I then run vncdotool (a python script compiled to .exe) to send keystrokes to the VNC server.

This is my AutoIT script. It works for the most part (a few machines consistently do not respond). I will track down what is up with those later.

#include <Constants.au3>

$AppName = "Lab Login"

$InputFileName =  ($CmdLine[0] = 0) ? StringReplace(@ScriptFullPath, ".exe", ".csv", -1) : $CmdLine[1]

If FileExists($InputFileName) Then
   $hInputFile = FileOpen($InputFileName, $FO_READ)
   If $hInputFile <> -1 Then
      $aLines = FileReadToArray($hInputFile)
      If @error = 0 Then
         For $i = 0 to UBound($aLines) - 1
            $aData = StringSplit($aLines[$i], ",")
            If $aData[0] = 3 Then
               Login($aData[1], $aData[2], $aData[3])
            EndIf
         Next
      Else
         MsgBox($MB_OK, $AppName, "Error reading file: " & $InputFileName)
      EndIf
      FileClose($hInputFile)
   Else
      MsgBox($MB_OK, $AppName, "Error opening file: " & $InputFileName)
   EndIf
Else
   MsgBox($MB_OK, $AppName, "File Not Found: " & $InputFileName)
EndIf

MsgBox($MB_OK, $AppName, "Finished processing (" & $InputFileName & ").")

Func Login ($Machine, $User, $Pass)
   $Dir = @ScriptDir & "\workers"
   $Params = " -p PASSWORD -s " & $Machine & " --delay=1500 key ctrl-alt-del key space type " & $User & " key tab type " & $Pass & " key enter"
   Run($Dir & "\vncdo.exe " & $Params, $Dir, @SW_HIDE)
EndFunc

I found this >post by The Kandie Man in a >thread about VNC and AutoIT (emphasis added):

 

 

I am just curious, why do you want to run the tightVNC viewer in an AutoIt GUI? Is there any particular reason for this? Do you wish to automatically login by using AutoIt? If so, I have written a simple script that does this.

 

 

That is the only thing I could find that doesn't seem to be dealing with having to interact with a VNCViewer window. So, I am wondering if anyone knows where I might find that script or how to accomplish this (remotely initiate a local login OR send just keystrokes to a VNC server - no mouse/screencast required) using only AutoIT. I am trying to make this as close to one-click (or drag-&-drop) for the end user as possible. I plan on throwing in a GUI with progress bar and such, but I want the core functionality rock solid before I bother with that.

Link to comment
Share on other sites

  • Moderators

You can set the local login for a machine. Google "automatic logon windows 7" and the first hit is a TechNet article that explains it pretty well. Basically, create a locked down user account that can only do so much, then set that account to automatically login when the machine boots up. If the teacher needs to do something else, instruct them on using RunAs.

Edited by JLogan3o13

"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

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