Search code examples
windowsuser-interfacejenkinscommand-lineautoit

How open GUI program with Autoit from Jenkins


I need to automate a Windows GUI program which runs in Windows. To do this I set up a Windows 2012 R2 machine on AWS, I installed Autoit on it and I wrote the script that launches the GUI program and does stuff on it (let's call this script auto.au3).

I run this script from Windows command line passing a parameter to it, and it works perfectly. The problem is that I need to launch it from Jenkins, and when I call the auto.au3 through the job the script seems not to be able to open the GUI program.

I configured Jenkins as slave on Windows (so I call it from my "main" Jenkins), enabled the "allow service to interact with the desktop", I added Autoit installation directory as a PATH environment variable to Jenkins and I wrote the batch command (which works directly on Windows) in Jenkins. Looks like this (%domain% is a jenkins build parameter):

SET PATH=%PATH%;%AUTOIT_PATH%

AutoIt3 C:\Users\Administrator\Desktop\auto.au3 param1 "%domain%"

The first step on auto.au3 is:

Run("C:\Program Files (x86)\GUIprogram.exe")

which works fine when executed from Windows but when launched from Jenkins does not open the program and the job gets stuck.

I also tried creating a python script that runs auto.au3 script to check if the error was in the PATH environment variable, but I checked that python works fine until it runs auto.au3, and then it also gets stuck at the first step. Again, only happens when I call it from Jenkins. If I execute it logged in on the machine and running the batch command directly, it works.

Is there some restriction that avoids launching GUI programs through Jenkins? Did I missed some configuration to allow it?

Thank you very much!

--EDIT------

I started the application and and removed the "launch app" code line, and still it's not doing nothing. Seems that auto.au3 is not doing nothing at all.


Solution

  • Ok so after many investigation, I found out that the issue was with the way the slave Jenkins was launched. I found the solution on this stackoverflow question response: https://stackoverflow.com/a/21409578/4269527

    The question wasn't really related, but the Jason Swager's response fixed the problem.