如何运行具有特定名称的空后台进程?

发布于 2024-10-22 01:43:19 字数 243 浏览 11 评论 0原文

我想让某个进程始终在后台运行,这样就可以在 Windows 的任务管理器中查看它,并使用我给它指定的具体名称。

该进程实际上不应该做任何事情,我所关心的是每当我打开任务管理器并选择“进程”时查看进程名称。

实现此目的的一种方法是复制 Notepad.exe ,将其名称更改为某个名称,然后运行它。问题是我不想每次使用电脑时都打开记事本窗口。我需要它在后台运行。

如果有的话,我有 Windows 7。

谢谢。

I want to have a certain process always running in the background so it will be viewable in the Task Manager of windows, with the specific name I give it.

The process shouldn't do anything really, all I care about is to see the process name whenever I open the task manager and choose "processes".

One way to achieve this is to copy Notepad.exe , change its name to something and then run it. The problem is I don't want to have an open window of notepad everytime I'm using the PC. I need it to run on background.

If it matters, I have Windows 7.

Thank you.

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

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

发布评论

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

评论(3

爱冒险 2024-10-29 01:43:19

您正在寻找这样的东西:

#include <windows.h>

int APIENTRY _tWinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR    lpCmdLine,
    int       nCmdShow
)
{
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    return 0;
}

这是最简单的 Windows 程序。它绝对不执行任何操作,也不消耗 CPU。

我无法想象你为什么想要它,但这就是你所描述的!

You are looking for something like this:

#include <windows.h>

int APIENTRY _tWinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR    lpCmdLine,
    int       nCmdShow
)
{
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    return 0;
}

This is the most simple Windows program. It does absolutely nothing and does not consume CPU.

I can't imagine why you want it, but this is what you describe!

农村范ル 2024-10-29 01:43:19

这是最小的 C# 版本:

static class Program
{
    [System.STAThread]
    static void Main()
    {
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    }
}

您可以从命令行编译它:

csc /target:winexe MyProg.cs

Here's a minimal C# version:

static class Program
{
    [System.STAThread]
    static void Main()
    {
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    }
}

You can compile this from the command line:

csc /target:winexe MyProg.cs

泅渡 2024-10-29 01:43:19

好吧,如果最小化的 DOS 窗口不打扰您,那么这个 DOS 命令将非常轻量并且可以为您完成工作:start /min more

Well if a minimized DOS window doesn't bother you then this DOS command will be very light weight and will do the job for you: start /min more

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