Process类的使用

 Process process= new Process();
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.FileName = "Cmd.exe";
            process.StartInfo.RedirectStandardInput = true;   
            process.StartInfo.RedirectStandardOutput = true;  
            process.StartInfo.RedirectStandardError = true;
            process.Start();
            process.StandardInput.WriteLine("net user " + _username + " " + _password);
            process.StandardInput.WriteLine("exit");
            process.WaitForExit();
            process.Close();

直接调用

 Process.Start("Cmd.exe", "/c " + "net user " + _username + " " + _password);
原文地址:https://www.cnblogs.com/EthanSun/p/3183955.html