How to hide a console application in C#

前端 未结 9 1873
刺人心
刺人心 2020-12-06 09:27

I have a console application in C#, and I want that the user won\'t be able to see it.

How can I do that?

9条回答
  •  猫巷女王i
    2020-12-06 10:11

    The best way is to start the process without window.

            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.Arguments = "echo Hello!";
            //either..
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            //or..
            p.StartInfo.CreateNoWindow = true;
            p.Start();
    

    See other probable solutions -

    Toggle Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden at runtime

    and,

    Bring another processes Window to foreground when it has ShowInTaskbar = false

提交回复
热议问题