给python流程一个Windows的名称或标题

发布于 2025-01-18 14:42:23 字数 370 浏览 1 评论 0原文

我有多个python脚本,它们一直在后台运行。我需要区分它们。因此,我考虑提供每个脚本,例如任务管理器 Process Explorer 中显示的名称或标题。 从我搜索的内容来看,这在 linux 中是可能的,而 Windows 则不可能。 我尝试了一个模块 setProctitle ,但它不起作用。

我尝试使用pytoexe,它有效,但是很难,因为每次您编辑代码时都需要生成EXE文件。

是否有任何便携式方法可以将每个Python脚本一个名称显示在 Process Explorer 中?

I have multiple python scripts that keep running in background. I need to distinguish between them. So I think about giving every script like a name or title that shows up in task manager or PROCESS EXPLORER .
From what I searched, this is possible in Linux, and impossible in windows.
I Tried a module SETPROCTITLE but It didn't work.

I tried using pytoexe, It works but It's difficult as It requires to generate an exe file every time you edit your code.

Is there any portable method to give every python script a name that display it in PROCESS EXPLORER ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

司马昭之心 2025-01-25 14:42:23

许多应用程序都有数十亿个实例很难区分。

在任务管理器中,我使用“详细信息”选项卡。右键单击“列标题”之一,然后从上下文弹出菜单中选择“选择列”。如果选择“命令行”列(并使窗口足够宽),则可以通过脚本的名称区分Python进程。

我敢肯定,Process Explorer也可以显示命令行,但是我不经常使用它来记住细节。

Lots of applications have zillions of instances that can be hard to distinguish.

In Task Manager, I use the Details tab. Right click on one of the column headers, and choose "Select columns" from the contextual pop-up menu. If you select the "Command line" column (and make your window wide enough), you might be able to distinguish between your python processes by the name of the script.

I'm pretty sure Process Explorer can also show the command line, but I don't use it frequently enough to remember the details.

美煞众生 2025-01-25 14:42:23

安装 pyinstaller 并创建 .exe 文件:

pyinstaller --onedir main.py

Install pyinstaller and create a .exe file:

pyinstaller --onedir main.py
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文