vb.net 如何在系统启动时运行控制台应用程序,而不将其显示在显示屏上(后台进程)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14133053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 11:44:34  来源:igfitidea点击:

How to run a console application on system Startup , without appearing it on display(background process)?

c#.netvb.netc#-4.0

提问by Praveen Kumar

I want to run a console application on system start up without appearing it on display screen means i want to run a application as a background process.How to do this?

我想在系统启动时运行控制台应用程序而不在显示屏上显示它意味着我想将应用程序作为后台进程运行。如何执行此操作?

采纳答案by Praveen Kumar

You can change the output type in project properties as console Application type to Windows application type and compile it, Then it won't display any window at start up.

您可以将项目属性中的输出类型从控制台应用程序类型更改为 Windows 应用程序类型并编译它,然后它不会在启动时显示任何窗口。

回答by Yusubov

In short:The simplest way might be to schedule taskto be started from your operating system. This might be the way easiest thing to set.

简而言之:最简单的方法可能是安排任务从您的操作系统启动。这可能是最简单的设置方式。

You may easily run it in the background with the scheduler - How to run a .Net Console App in the background

您可以使用调度程序轻松地在后台运行它 -如何在后台运行 .Net 控制台应用程序

回答by Umesh CHILAKA

Try this to hide the console window and run in background

试试这个隐藏控制台窗口并在后台运行

[DllImport("user32.dll")]
private static extern int ShowWindow(int Handle, int showState);

[DllImport("kernel32.dll")]
public static extern int GetConsoleWindow();


public static void HideWindow()
{
    int win = GetConsoleWindow();
    ShowWindow(win, 0);
}

why dont you try windows service ? windows service runs the process in background.

你为什么不试试windows服务?windows服务在后台运行该进程。