How to launch Multilogin X desktop app via script
You can use the scripts below to launch the app. It is useful for automation and can be combined with the other scripts we share in our knowledge base.
The agent needs a display in order to work. If your system doesn’t have one, use a virtual display. Example (for Linux):
xvfb-run mlx
Windows
Run the script via IDE or Command Prompt. Don't know how? Read this article: Getting started with automation scripting.
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'C:\\Users\\AntonLa\\AppData\\Local\\Multilogin X App\\MLXDesktopApp.exe'
agent_connection = subprocess.run([exe_path])
assert agent_connection.returncode == 0
if agent_connection.returncode == 0:
print("Agent connected")
else:
print(f"Failed to connect agent. Error {agent_connection.returncode}")
if __name__ == "__main__":
connect_agent()
macOS
Run the script via IDE or Terminal. Don't know how? Read this article: Getting started with automation scripting.
import subprocess
def connect_agent():
agent_connection = subprocess.Popen(['open', '/Applications/Multilogin X App.app/'])
agent_connection.wait()
return_code = agent_connection.returncode
if return_code == 0:
print("Agent connected")
else:
print(f"Failed to connect agent. Error {return_code}")
connect_agent()
Linux
Run the script via IDE or Terminal. Don't know how? Read this article: Getting started with automation scripting.
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'/opt/mlxapp/desktop.bin'
agent_connection = subprocess.run([exe_path])
assert agent_connection.returncode == 0
if agent_connection.returncode == 0:
print("Agent connected")
else:
print(f"Failed to connect agent. Error {agent_connection.returncode}")
if __name__ == "__main__":
connect_agent()