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);
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.
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.
-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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With