Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Process hidden?

Tags:

I start a Console Application via ProcessStartInfo and process.Start(). I want to hide the black window. Here's my code:

string output = ""; //Setup the Process with the ProcessStartInfo class ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "C:\\WINNT\\system32\\cmd.exe"; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true;  //Start the process Process proc = Process.Start(startInfo); 
like image 348
Thu marlo Avatar asked Jul 28 '11 09:07

Thu marlo


People also ask

How do I Run a PowerShell script without displaying Windows?

I found out if you go to the Task in Task Scheduler that is running the powershell.exe script, you can click "Run whether user is logged on or not" and that will never show the powershell window when the task runs.

What does :: mean in PowerShell?

Static member operator :: To find the static properties and methods of an object, use the Static parameter of the Get-Member cmdlet. The member name may be an expression. PowerShell Copy.

What is ArgumentList in PowerShell?

-ArgumentList. Specifies parameters or parameter values to use when this cmdlet starts the process. Arguments can be accepted as a single string with the arguments separated by spaces, or as an array of strings separated by commas.

What is PowerShell WindowStyle hidden?

Most malicious PowerShell scripts run PowerShell with the window style “Hidden”. When the process starts with WindowStyle hidden, no PowerShell console is displayed, so it runs unnoticed for the logged-in user. I created a script to unhide all PowerShell processes.


1 Answers

The final answer is

 ProcessStartInfo psi = new ProcessStartInfo();  psi.FileName = ....  psi.RedirectStandardInput = true;  psi.RedirectStandardOutput = false;  psi.Arguments =...  psi.UseShellExecute = false; 

psi.CreateNoWindow = true; // <- key line

like image 197
Oumdaa Avatar answered Sep 22 '22 14:09

Oumdaa