I am trying to make my python script to start on windows boot. I have managed to start with registry, shortcut in startup folder and taskscheduler. However, windows stops the script immediately. This does not persist if I use the same start command on CMD or double clicking the shortcut. Only when trying to get it start automatically.
One more problem i have noticed, that when i run script with .pyw extension nothing happens. But it works if i use pythonw in CMD. Not sure if that has to do anything with the problem.
I am using Windows 10, python 3.7 and this is my code:
from serial import Serial
from time import sleep
ser = Serial('COM7', 9600)
while True:
ser.write(b'1')
sleep(1)
Launch script:
pythonw "%UserProfile%\PyCharm\hearthbeat\hearthbeat.pyw"