Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# silent execute exe

ProcessStartInfo psi = new ProcessStartInfo();            
psi.FileName = "netsh";            
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.Arguments = "SOME_ARGUMENTS";

Process proc = Process.Start(psi);                
proc.WaitForExit();
string errorOutput = proc.StandardError.ReadToEnd();
string standardOutput = proc.StandardOutput.ReadToEnd();
if (proc.ExitCode != 0)
    throw new Exception("netsh exit code: " + proc.ExitCode.ToString() + " " + (!string.IsNullOrEmpty(errorOutput) ? " " + errorOutput : "") + " " + (!string.IsNullOrEmpty(standardOutput) ? " " + standardOutput : ""));
Comment

PREVIOUS NEXT
Code Example
Csharp :: add css class based on model value razor 
Csharp :: how to make game restart when player touches a object unity 
Csharp :: how to add an embedded resource in visual studio code 
Csharp :: Query mongodb collection as dynamic 
Csharp :: c# remove exit icon 
Csharp :: Convert C# Class to xml wth xsd.exe 
Csharp :: system.text.json ways to go about getting to the data how to get the data text.json you should use JsonDocument when 
Csharp :: record keyword c# 
Csharp :: Maximize Print Preview 
Csharp :: quine in c# 
Csharp :: The anti-forgery cookie token and form field token do not match. 
Csharp :: asp.net mvc select from many to many relationship 
Csharp :: asp.net core relative file path within console app 
Csharp :: ASP.MVC display image from SqlServer 
Csharp :: unity move in x seconds to pos 
Csharp :: unity number generator 
Csharp :: c# return propertty from each object in object lpist 
Csharp :: how to initialize array in c# 
Csharp :: how to change an object color with fill c# 
Csharp :: c# exec command output 
Csharp :: asp.net core user.identity.name is null 
Csharp :: @using System,System.Core 
Csharp :: c# check if username and password is true 
Csharp :: openiddect ef core table not creating 
Csharp :: how to destroy bridges animal crossing 
Csharp :: how to add the ssl certificate in vb.net application 
Csharp :: make wpf run in fullscreen but above windows taskbar 
Csharp :: Hangfire Creation Table With EFCore 
Csharp :: dotnet target specific framework 
Csharp :: asp.net mvc table array binding arbitrary indices 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =