WernerMilis Posted June 23, 2009 Posted June 23, 2009 Hi, is it possible to run an autoit script on a server using a scheduled task? This script would have to send keystrokes (open an application, log in, perform a query, close the application). All of this without an active session. The goal is to do some performance monitoring with the script by executing a standard query each half hour without being connected to the server. thanks in advance for your feedback. Best Regards, Werner
nguyenbason Posted June 23, 2009 Posted June 23, 2009 Register it as a service. UnderWorldVN- Just play the way you like it
WernerMilis Posted June 24, 2009 Author Posted June 24, 2009 Hi, this is my script: Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase $file = FileOpen("c:\autoit\output.csv",1) if $file = -1 Then msgbox(0, "Error", "Unable to open c:\autoit\output.csv") Exit EndIf ;Start Remedy FileWriteLine($file, PrintLine("01. Start Full Client executable")) Run("D:\Program Files\AR System\User\aruser.exe") WinWait("Login - BMC Remedy User") WinActivate("Login - BMC Remedy User") FileWriteLine($file, PrintLine("02. Full Client executable started - entering login data")) ;Login Send("xxx{TAB}xxx{TAB}{TAB}{TAB}{TAB}{ENTER}xxx{TAB}xxx{TAB}{TAB}{TAB}{ENTER}") FileWriteLine($file, PrintLine("04. Login data provided, logging in")) WinWait("BMC Remedy User - [Home Page (Search)]") WinActivate("BMC Remedy User - [Home Page (Search)]") FileWriteLine($file, PrintLine("05. Logged in, Homepage presented, starting to open the Object list")) ;Open the Object List send("^o") WinWait("Object List") WinActivate("Object List") FileWriteLine($file, PrintLine("06. Object list opened, looking for the incidents form")) ;Open the Incidents form in search mode send("!n") send("Incidents{ENTER}") send("{TAB}{TAB}{DOWN}{ENTER}") WinWait("BMC Remedy User - [incidents (Search)]") WinActivate("BMC Remedy User - [incidents (Search)]") FileWriteLine($file, PrintLine("07. Incidents form opened in search mode")) ;Fill in the advanced search criterium send("^e") send("!s") sleep(500) send("'3' > $DATE$","1") FileWriteLine($file, PrintLine("08. Search criterion entered, starting search")) send("^{ENTER}") WinWait("BMC Remedy User - [incident (Modify)]") WinActivate("BMC Remedy User - [incident (Modify)]") FileWriteLine($file, PrintLine("09. Search result returned")) ;Close Remedy FileWriteLine($file, PrintLine("10. Closing Remedy")) send("!{F4}") FileWriteLine($file, PrintLine("11. Remedy Closed")) filewriteline($file, "***" & @CRLF) FileClose($file) Exit Func PrintLine($ToPrint) $ToPrint = $ToPrint & ";" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "," & @MSEC & @CRLF return $ToPrint EndFunc But when I look in the output file, I see that, with no open sessions, the script always fails after step 2: 01. Start Full Client executable;24/06/2009 07:00:00,140 02. Full Client executable started - entering login data;24/06/2009 07:00:00,656 04. Login data provided, logging in;24/06/2009 07:00:01,359 01. Start Full Client executable;24/06/2009 07:30:00,140 02. Full Client executable started - entering login data;24/06/2009 07:30:00,656 04. Login data provided, logging in;24/06/2009 07:30:01,359 01. Start Full Client executable;24/06/2009 08:00:00,203 02. Full Client executable started - entering login data;24/06/2009 08:00:00,703 04. Login data provided, logging in;24/06/2009 08:00:01,406 01. Start Full Client executable;24/06/2009 08:30:00,171 02. Full Client executable started - entering login data;24/06/2009 08:30:01,734 04. Login data provided, logging in;24/06/2009 08:30:02,703 Does somebody see anything wrong in the script? When I have an open session, and the script executes, it executes correctly...
spudw2k Posted August 21, 2009 Posted August 21, 2009 Unless I'm mistaken, if there's no session then you cannot interact with the desktop properly and thus winwait and winactive funcs will not work. Anyone dispute? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now