Jump to content

Running an autoit script on a server without any open session


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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?

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