Cách khởi chạy ứng dụng Multilogin trên máy tính để bàn thông qua tệp lệnh
Sử dụng script Python để khởi động ứng dụng máy tính để bàn Multilogin trên Windows, macOS hoặc Linux trước khi chạy các quy trình tự động hóa cục bộ khác.
➡️ Chọn script cho hệ điều hành của bạn → cập nhật đường dẫn ứng dụng nếu cần → chạy script từ IDE hoặc terminal.
Sử dụng cách này khi quy trình tự động hóa của bạn cần ứng dụng máy tính để bàn Multilogin và trình khởi chạy tích hợp chạy trước.
Agent cần có màn hình để hoạt động. Nếu hệ thống của bạn không có, hãy sử dụng màn hình ảo. Ví dụ (cho Linux):
xvfb-run mlx
Trước khi bắt đầu
Đảm bảo rằng:
- Ứng dụng máy tính để bàn Multilogin đã được cài đặt
- Python đã được cài đặt
- Bạn biết cách chạy script Python từ IDE hoặc terminal
- Trên Linux, có môi trường hiển thị đồ họa hoặc đã cấu hình màn hình ảo được hỗ trợ
Windows
Chạy tập lệnh thông qua IDE hoặc Command Prompt. Bạn chưa biết cách? Hãy đọc bài viết sau: Bắt đầu với tập lệnh tự động hóa.
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'C:\\Users\\AntonLa\\AppData\\Local\\MultiloginX 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
Chạy tập lệnh qua IDE hoặc Terminal. Bạn chưa biết cách? Đọc bài viết sau: Bắt đầu với tập lệnh tự động hóa.
import subprocess
def connect_agent():
agent_connection = subprocess.Popen(['open', '/Applications/MultiloginX 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
Chạy tập lệnh qua IDE hoặc Terminal. Bạn chưa biết cách? Đọc bài viết sau: Bắt đầu với tập lệnh tự động hóa.
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()