One Python Script One GUI application

Python Script does two things, currently launches at boot up of windows 10 OS, via the Common Startup folder. Python Script is running as server software to communicate status and simple commands back and forth between an an Arduino board and client desktop. The second task is to monitor the GUI application. Recognizes if the GUI crashes, logs the crash, and then relaunches the application.

GUI Application also has two mode's. The first mode is manual mode. A user, who chooses to remote into the board, can operate an externally connected device/sensor. Giving the user full control. Mode two is an automation mode. This mode is enabled by default, and will implement routines to control the externally connected device/sensor. The GUI has a disable button to disable the automation mode, and enter the manual mode. The GUI was written in C++ with visual studio, using MFC for the GUI.

That's the background.

What I'm looking for is information on how to launch both the python script and the GUI Application on a headless system, so that when/if a user remotes into the desktop, they can interact with the GUI.

What I've done.

The first thing I tried was to load the python script into the startup folder. However, this folder only operates when a user logs on. So I did some more digging and found task scheduler. Running task scheduler sort of worked. It launched the python script just fine, and the python script launched the GUI application, but it was launched as a background process. So I couldn't interact with the GUI. The latest thing I've attempted was to move the python script into the Common Startup folder. This folder differs with the Startup folder by launching any application contained within at boot up, not when a user logs in. While, the python script launched just fine, the GUI only launches after a user logs in, so you will need to remote in to launch the GUI.

This system will be running for hours on end, without anyone logged in or paying attention to it. So the python script will need to be able to launch the GUI application, so that when/if someone logs into it they can make adjustments via the manual mode.

The python script launches the GUI application via a separate thread

overWatch = threading.Thread(target=cmd.overWatch, daemon=True)

def overWatch():

    global relaunch

    while True:
        if relaunch == True:

            if  not checkIfProcessRunning(AIRIS):
                print("Attempt to launch")

Anyone have any insight?


So my issue wasn't necessarily one of the system not wanting to launch the GUI if a monitor wasn't connected, headless. It was more that Windows doesn't want to launch any UI's before a user was logged in.

So it was an easy solution. I setup the system to auto-login.

Open run command box and type . A user account window will pop up. Select the user you want to have auto-login. Next uncheck the "Users must enter a user name and password to use this computer" box. Click apply and you will be prompted for the user password to confirm.

The GUI for application now launches and does what it needs to do. When I am ready I can remote onto the SBC and interact with it if I need to. Close the connection and everything is good.

Obviously, this opens up potential security issues. In my particular situation there are no concerns as this is an internal product we are testing.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.