Running Python Script as a Windows background process [duplicate]

Deadly 提交于 2019-12-28 13:22:22

问题


I have been trying to code a python script which reads data from a serial port. It worked well from the command line but I need it to run as a background process without any command line interface. The script has a while loop which reads the next byte of data from a serial port and simulates a key press accordingly. For the keypresses to be focused on the current window, instead of python command line, I need the script to run as a background process. I have read few answers here but nothing rang a bell for me. Please point me in the right direction.


回答1:


On Windows, you can run a Python script in the background using the pythonw.exe executable. This will run your program in the background, with no visible process or way to interact with it. You also cannot terminate it without a system monitor. More information on pythonw.exehere: pythonw.exe or python.exe?

Best of luck!



来源:https://stackoverflow.com/questions/32808730/running-python-script-as-a-windows-background-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!