Jump to content

Unable to run script remotely using task schedular

Recommended Posts

Dear All, Good Day

I have created an Autoit script which runs perfectly on local machine,but when i call the same script from a remote machine it failed (window in disable mode, every time when i click manually the screen the script will work). Even i tried mouseclick but failed, please advise. 


Note: My ultimate aim is to automate the task using a automation scheduler which installed on a separate system.

Please check my below script

Run("C:\Program Files (x86)\ITProgararm\prgm.exe")
WinWaitActive("Log into Database Server")

WinWaitActive("ITProgararm - Program Monitor","")
WinWaitActive("ITProgararm - Program Monitor - [Authorizers]","")
WinWaitActive("ITProgararm - Program Monitor - [Authorizer VASA Information]","")


Thanks in advance



Link to post
Share on other sites

Hi Ganesh,

To clarify what you're saying so we're on the same page. Yes if your application relies on GUI elements, such as sending keys to a visible window (can be hidden as well) then it will not work when the session is entirely in the background. For example, an executable that relies on task manager to execute it when the user is no longer logged on will not work. 


There are several ways around this that I've found.

  1. Make the application not rely on GUI elements, programs usually have some sort of command line console that you can work with, websites and webforms have the invoke web request with powershell which AutoIT has a version of.
  2. Leave your session logged in. This may or may not work depending on your application, but leaving your profile logged in in the lock position will allow some GUI dependent executables to run without a problem. As for disconnecting, I have not had any success with it, although I am open to the possibility.
  3. Get a virtual machine involved.

Also, instead of simply using the send function. I would recommend that you use the ControlSend function. In fact I recommend trying this out first. This is a sample from a working IE script I am using:


Local $hWnd = _IEPropertyGet($oIE, "hwnd")
    _IEAction($oSubmit, "focus")
    ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

ControlSend sends the keys directly to the control itself and doesn't rely on an application being in focus so that perhaps might help you in a combination of the above possibilities.

If you are intent on using control send, you could always use the AU3Info tool under Tools in SciTE to better scout out the controls.


Link to post
Share on other sites

ControlClick, and ControlSetText...and keep this in mind:


If you are actually working on a desktop...then instead of waiting for a window to become active (winwaitactive), you can wait for it to exist, or loop until wingethandle returns a handle, and then winactivate it.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to post
Share on other sites

Thanks, it worked with ControlSend and ControlClick

Dear BananaFish and JDELANEY,

Have A Good Day

Thanks for your comments.

I have modified the script using ControlSend and ControlClick functionality instead Send and MouseClick respectively now things are workig as expected.

Happy Coding

Thanks & Regards


Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CiaronJohn
      I would like to read the output of my cygwin terminal if it is already up and running.
      I searched the forum, but I think, the samples were cmd/cygwin needs to be re-run or not yet running.
      The purpose of the script is to check if compiling is done.
      Func _JAE_Rebuild_Software ($sSoftwarePath)
          Local $iMinty = 0
          ; Open cygwin process and check one instance only
          if ProcessExists("mintty.exe") Then
              $iMinty = ProcessExists("mintty.exe")
              ; Run cygwin if not yet running
              $iMinty = Run("C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -", "", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
          ; Loop to check if cygwin terminal is ready
          While 1
              ; if -sh is not error cygwin is still opening
              Local $hWnd = WinGetHandle("-sh")
              If @error Then
                  $hWnd = WinGetHandle("~")
                  $hWnd = 0
              ; If true cygwin is ready to be written
              if $hWnd <> '0x00000000' Then
          ; Change Directory
          $sSoftwarePath = StringReplace($sSoftwarePath,"\", "/")
          Send('cd ' & $sSoftwarePath & "{ENTER}" )
          ; Get New Class after Change Directory
          Local $sNewClass = WinGetTitle("[ACTIVE]")
          ; Sleep for 3 seconds.
          ; Change software path to access the makeFile
          $sSoftwarePath = StringReplace($sSoftwarePath,"/", "\")
          ; Open Makefile
          Local $hFileOpen = FileOpen($sSoftwarePath & "\makefile", $FO_READ)
          If $hFileOpen = -1 Then
              Return False
          Local $sFileRead = FileReadLine($hFileOpen, 12)
          Local $sSetSource = _StringBetween($sFileRead, "(", ")", $STR_ENDNOTSTART)
          Local $message
          Send('source ' & $sSetSource[0] & '.sh' & "{ENTER}")
          Send('make clean' & "{ENTER}")
          WinActivate($sNewClass, "")
          $hWnd = WinWait($sNewClass,"",1)
          Local $iPID = WinGetProcess($hWnd)
          While $iMinty
              $message &= StderrRead($iPID)
               If @error Then
         ; I only get blank output here since the while condition produces an error
         MsgBox(0, "Stdout Read:", $message)
      EndFunc ;==>_JAE_Rebuild_Software
    • By Command3r
      Hello, is there anyway to make a gui with autoit and put it in another programming language??

      I want make a program with visual basic but in the same time i want to get some functions and GUIs from autoit.

      All helps and ideas are appreciated.
  • Create New...