如何在后台运行python脚本?

时间:2022-04-21 01:14:51

I have a script that checks something on my PC every 5 minutes and I don't want Python to show on my task tray. I use Windows as my operating system.

我有一个脚本,每5分钟检查一次我的电脑上的内容,我不希望Python显示在我的任务托盘上。我使用Windows作为我的操作系统。

Is there any way to make Python run in the background and force it to not show in my task tray?

有没有办法让Python在后台运行并强制它不显示在我的任务托盘中?

5 个解决方案

#1


0  

Look for Schedule Tasks in the control panel.

在控制面板中查找“计划任务”。

#2


43  

If you run a console script using pythonw.exe, it will neither display a window nor appear in the task bar. For example, I use the following command to launch ntlmaps on startup:

如果使用pythonw.exe运行控制台脚本,它既不会显示窗口也不会显示在任务栏中。例如,我使用以下命令在启动时启动ntlmaps:

C:\BenBlank\Python2.6\pythonw.exe scripts/ntlmaps

Be aware, however, that there is no way to interact with the script, nor to terminate it save via the Task Manager.

但请注意,无法通过任务管理器与脚本进行交互,也无法终止它。

#3


3  

Just another option you have:

你有另一种选择:

You can create a shortcut to your Python script, then right-click the shortcut --> Properties --> Shortcut tab

您可以创建Python脚本的快捷方式,然后右键单击快捷方式 - >属性 - >快捷方式选项卡

There is a drop-down box under the Run option which lets you run the command minimized.

“运行”选项下有一个下拉框,可让您最小化运行命令。

#4


1  

cron it on linux; schedule it on windows [control panel > scheduled tasks > Add scheduled task]

cron it on linux;在Windows上安排它[控制面板>计划任务>添加计划任务]

#5


1  

You could run it as a service. See here

您可以将其作为服务运行。看这里

#1


0  

Look for Schedule Tasks in the control panel.

在控制面板中查找“计划任务”。

#2


43  

If you run a console script using pythonw.exe, it will neither display a window nor appear in the task bar. For example, I use the following command to launch ntlmaps on startup:

如果使用pythonw.exe运行控制台脚本,它既不会显示窗口也不会显示在任务栏中。例如,我使用以下命令在启动时启动ntlmaps:

C:\BenBlank\Python2.6\pythonw.exe scripts/ntlmaps

Be aware, however, that there is no way to interact with the script, nor to terminate it save via the Task Manager.

但请注意,无法通过任务管理器与脚本进行交互,也无法终止它。

#3


3  

Just another option you have:

你有另一种选择:

You can create a shortcut to your Python script, then right-click the shortcut --> Properties --> Shortcut tab

您可以创建Python脚本的快捷方式,然后右键单击快捷方式 - >属性 - >快捷方式选项卡

There is a drop-down box under the Run option which lets you run the command minimized.

“运行”选项下有一个下拉框,可让您最小化运行命令。

#4


1  

cron it on linux; schedule it on windows [control panel > scheduled tasks > Add scheduled task]

cron it on linux;在Windows上安排它[控制面板>计划任务>添加计划任务]

#5


1  

You could run it as a service. See here

您可以将其作为服务运行。看这里