1

I have a AutoIt script that I need to start when a RemoteApp session is created.

The script waits for a window to appear and then extracts the text of a certain label and writes it to a file.

I already have this script and it works fine when I run it manually but if I set the script to start through a scheduled task on logon or by group policy it doesn't appear to have access to the windows that appear in the session.

It appears that the process doesn't have interactive access to the session but how would I go about starting it so that it does?

Here's the AutoIt script in question

Local $WindowName = "Infinity Cash Out"
Local $ClientName = EnvGet("CLIENTNAME")
Local $Filename = "S:\Pole\" & $ClientName & ".txt"

While(true)
    $hWnd = WinWait("[TITLE:Infinity Cash Out]")
    $sText = ControlGetText($hWnd, "", "[NAME:CurrTotal]")
    $sText = StringMid($sText, 1, StringInStr($sText, ".") + 2)
    $sText = "Total:" & @CRLF & $sText

    $file = FileOpen($Filename, 2)
    FileWrite($file, $sText)
    FileClose($file)

    WinWaitClose($hWnd)

    $file = FileOpen($Filename, 2)
    FileWrite($file, "")
    FileClose($file)
WEnd
  • Not that this may work long term, but what happens if you run the script via the Startup folder? Also, what version of Windows? – Twisty Impersonator Dec 14 '16 at 22:32
  • If I put it in the startup folder it will only start with a full RDP session. – Daniel Radtke Dec 15 '16 at 14:33
  • 1
    For now I've found a solution but it's not really an answer to the question... What I've done for now is make a launcher app that is limited to one instance per session and I have that in turn launch the exe that I pass in the arguments... The downside of course is that every RemoteApp has to be launched through this app but at least it does the job... – Daniel Radtke Dec 15 '16 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.