简体   繁体   中英

How can I make a program run in the background from a console application in c#

Hi there I am currently working on a Console Application that run's a .bat file and when the program starts it pops up as the main box on my window and as this is running several times a min, this can get a little annoying is there any way when I run this command...

System.Diagnostics.Process.Start(@"newmessage1.bat");

is there a way of making the .bat cmd window running in a kinda hidden state?

You could play around a little with the CreateNoWindow and UseShellExecute properties:

var psi = new ProcessStartInfo
{
    FileName = "newmessage1.bat",
    CreateNoWindow = true,
    UseShellExecute = false
};
Process.Start(psi);

Use the ProcessStartInfo.CreateNoWindow property.

Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.FileName = @"newmessage1.bat";
myProcess.Start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM