[英]How to run a python script in the background?
我有一个脚本每 5 分钟检查一次我的 PC 上的某些内容,我不希望 Python 显示在我的任务托盘上。 我使用 Windows 作为我的操作系统。
有没有办法让 Python 在后台运行并强制它不在我的任务托盘中显示?
如果您使用pythonw.exe
运行控制台脚本,它既不会显示窗口,也不会出现在任务栏中。 例如,我使用以下命令在启动时启动ntlmaps :
C:\BenBlank\Python2.6\pythonw.exe scripts/ntlmaps
但是请注意,无法与脚本交互,也无法通过任务管理器终止它保存。
你还有另一个选择:
您可以创建 Python 脚本的快捷方式,然后right-click the shortcut --> Properties --> Shortcut tab
“运行”选项下有一个下拉框,可让您运行最小化的命令。
您可以将其作为服务运行。 看这里
在 linux 上运行它; 在 Windows 上安排它 [控制面板 > 计划任务 > 添加计划任务]
从任何地方运行 python 文件:
第1步:
Create Shortcut of Python File.
第2步:
Place Shortcut in this location C:\ProgramData\Microsoft\Windows\Start Menu\Programs
第 3 步:
Now Right Click --> Go to Properties --> Shortcut --> Press any key on keyboard it will take one shortcut key
第四步:
Now , Type the Shortcut key which you entered in previous step.
第 5 步:
Check out Output! :)
在控制面板中查找计划任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.