I have a .pyw script that works when I double click it etc and it stays open till I close it but I've added it to the registry to run at startup. It does run on startup but it doesn't stay open like its set to. It flashes the gui and then just closes.
Any ideas why this is happening or how to fix it?
P.S I don't want to create a shortcut in the startup folder linking to the .pyw file.
I added the my python script to the registry with another python script :p
import _winreg
aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
aKey = _winreg.OpenKey(aReg, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, _winreg.KEY_WRITE)
_winreg.SetValueEx(aKey,"MyScript",0, _winreg.REG_SZ, myScript_path)
And when I browse that path in the registry: HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > CurrentVersion > Run it is there with the correct path in data and type REG_SZ
There was a very strange error that only happened at startup since one of the processes the script seemed to use hadn't been started yet. Running as a .py with python.exe didn't produce the error, it only happened when the script was run as a .pyw so I wrote the sys.stdout to a file to log its progress and errors.
Before I had used the logging module but it didn't seem to give as much detail as just outputting straight to file.
After checking the file I was able to fix the code so essentially it was a code problem but quite a sneaky one.