#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.12.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; Type is "ssh" or "scp" or "rdesktop" if($cmdline[0] >= 1) Then $host = $cmdline[1]; Else msgbox(0,0,"1. param is host, 2. param is ssh, scp or rdesktop") exit endif if($cmdline[0] >= 2) Then $type = $cmdline[2]; Else $type="scp" endif if($type=="rdesktop") Then $pwtype="rdesktop" Else $pwtype="ssh" endif $found = false $tc = getvol("TC"); global $user; global $host; global $pw; global $port; get_host_data(); #cs $user = "root" $host = "192.168.178.100" $port = "22000" $pw = "sag_ich_nicht:-)" #ce if($found == false ) Then TrayTip("Host not found","Host " & $host & " konnte nicht gefunden werden!",4000) sleep(4000) Exit endif $connstr = $user & "@" & $host if($type == "scp") Then $cmd = $tc & "\portableapps\WinSCPPortable\WinSCPPortable.exe """ & $user & ":" & $pw & "@" & $host & ":" & $port & """"; run($cmd) endif if($type == "ssh") Then $cmd = $tc & "\portableapps\puttyPortable\puttyPortable.exe -ssh -pw """ & $pw & """ """ & $connstr & """ " & $port ; run($cmd) WinWait("PuTTY Security Alert","The server's host ke",30) if WinExists("PuTTY Security Alert","The server's host ke") Then If Not WinActive("PuTTY Security Alert","The server's host ke") Then WinActivate("PuTTY Security Alert","The server's host ke") WinWaitActive("PuTTY Security Alert","The server's host ke") Send("{ALTDOWN}j{ALTUP}") endif endif if($type == "rdesktop") Then $cmd = "mstsc /v:""" & $host & """" ; run($cmd) Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Remotedesktopverbindung","Dieses Problem kann ",3) if(WinExists("Remotedesktopverbindung","Dieses Problem kann ")) Then If Not WinActive("Remotedesktopverbindung","Dieses Problem kann ") Then WinActivate("Remotedesktopverbindung","Dieses Problem kann ") WinWaitActive("Remotedesktopverbindung","Dieses Problem kann ") Send("{ALTDOWN}dj{ALTUP}") endif $title = $host & " - Remotedesktopverbindung"; WinWait($title,"",15) ;msgbox(0,0,"wait for win"); if(WinExists($title)) Then ;msgbox(0,0,"exists" & $title); WinActivate($title) WinWaitActive($title,"",5); endif if(winactive($title)) then sleep(5000) ;msgbox(0,0,"activate and login") WinActivate($title) WinWaitActive($title,"",5); send("{altdown}{b}{altup}" & $user); send("{altdown}{k}{altup}" & $pw); send("{ENTER}") Else msgbox(0,0,"rdesktop window not found! (" & $host & ")"); endif exit endif func get_host_data() $content = FileRead($tc & "\data\pws.txt") $splits = stringsplit($content,@crlf,0) for $s in $splits $s = StringReplace($s,@crlf,"") $s = StringReplace($s,@cr,"") $s = StringReplace($s,@lf,"") $do = true; if stringlen($s) <= 5 Then $do = False endif if(stringleft($s,1) == "#") Then $do = false endif if $do Then if(stringleft($s,stringlen($host)) = $host) Then $rest = stringright($s,stringlen($s)-stringlen($host) -1) if(stringleft($rest,stringlen($type)) = $pwtype) Then ; FOUND $found = True $tmp = stringsplit($rest," ") $user = $tmp[2]; $pw = $tmp[3]; if($tmp[0] >= 4) Then $port = $tmp[4] Else $port = "22" endif endif endif endif next EndFunc func getvol($type) if($type="SD") Then $file = "SDToken" EndIf if($type="TC") Then $file = "TCToken" endif $var = DriveGetDrive( "all" ) If NOT @error Then For $i = 1 to $var[0] $status = DriveStatus( $var[$i]); if($status = "READY") then ;if($var[$i] <> "a:" and $var[$i] <> "b:") then if(fileexists($var[$i] & "\" & $file)) Then return $var[$i] endif endif Next EndIf return false endfunc