pythonazure-pipelinesazure-agent

Python script can't start desktop app using azure devops agent


Good day.

I have python script.

import os os.startfile("calc.exe")

When I run this script from the command line it starts the calc app.

But I want to run this script by Azure pipeline. I have an agent, which log in under my credentials.

Pipeline have powershell script step, which runs python script.

And when I run the pipeline - nothing happens.

I've tried python subprocess module - but result is the same.


Solution

  • When calling the Python script to start an app (.exe) in pipeline runs on self-hosted agent, you can configure like as below:

    1. As stated in this documentation "Visible UI testing using self-hosted Windows agents", you need to configure the self-hosted agent as interactive mode with auto-logon enabled. With auto-logon setting, you need to provide the username and password that logs on the agent machine.

    2. After successfully configuring the self-hosted agent, restart the agent machine. Once restarted, you can see the Command Prompt is automatically opened to start and logon the agent.

    3. In the pipeline, you need to set the variable "Process.Clean" to "false".

      • By default, it is "true". With the "true" value, the started app window will be closed once the task is completed, as all the processes opened by the task would be cleaned. So, you might see the app window just flash by.

      • If setting the value to "false", the opened the app window will persist, even if the whole pipeline run has completed.