Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the CMD console from this code?

How to hide the console from within this code? Currently the cmd console is shown everytime I run this code.

protected override void OnStart(string[] args)
{            
    String applicationName = "cmd.exe";
    // launch the application
    ApplicationLoader.PROCESS_INFORMATION procInfo;
    ApplicationLoader.StartProcessAndBypassUAC(applicationName, out procInfo);

}

How can I execute a *.bat file from here? Can I simply can substitute the "cmd.exe" with "xxx.bat"?

like image 716
karikari Avatar asked Jun 26 '26 07:06

karikari


1 Answers

Add a System Reference to the code;

using System Diagnostics;

Then use this code to Hide the CMD Window and run.

Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.StartInfo.Arguments = "Your arguments";
cmd.Start();
like image 186
Jalal Said Avatar answered Jun 28 '26 21:06

Jalal Said