HOWEVER...
This works for me, but I need it to run as a service. I am using Send to send commands to the PuTTY window, which doesn't work when a user is not logged in. Does anyone have any suggestions on how to accomplish this?
;Tom Thomalla Jr. ;1/14/08 ;AHK Ver 1.0.47.04 ;PuTTY ver 0.58 ; ;AutoPuTTY ;logs into a telnet session with putty, and runs some commands #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. logfile = %A_ScriptDir%\putty.log ;NOTE: Must launch putty manually and setup this session name session = test session ;change the session name to the way it is in the registry stringreplace session2, session, %A_SPACE%, `%20 , 1 ;delete the log file before putty is launched filedelete %logfile% ;Change the location of the logfile if the script is moved RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\SimonTatham\PuTTY\Sessions\%session2%, LogFileName, %logfile% ;launch putty run,C:\Program Files\PuTTY\putty.exe -load "%session%" ;look at the log file file for the login prompt every 100ms loop { Loop, read, %logfile% last_line := A_LoopReadLine if last_line=login: break sleep 100 } ;Send the login name Send login name{ENTER} ;look at the log file file for the password prompt every 100ms loop { Loop, read, %logfile% last_line := A_LoopReadLine if last_line=password: break sleep 100 } ;Send the password Send password{ENTER} ;wait for a prompt loop { Loop, read, %logfile% last_line := A_LoopReadLine StringGetPos,pos,last_line,# if pos >=0 break sleep 100 } ;do something Send your command here{ENTER} ;wait for the prompt loop { Loop, read, %logfile% last_line := A_LoopReadLine StringGetPos,pos,last_line,# if pos >=0 break sleep 100 } ;logout Send exit{ENTER} ;wait for login prompt loop { Loop, read, %logfile% last_line := A_LoopReadLine if last_line=login: break sleep 100 } ;end session Send ^C^]{ENTER}