cmd

            Process p = new Process();//创建进程对象
            string drivename = cboDrive.Text;//盘符
            string shareName = txtShareName.Text;//共享名
            string sharePath = txtShareDisk.Text;//共享路径
            p.StartInfo.FileName = "cmd";//启动进程名称
            //磁盘格式转换
            //p.StartInfo.Arguments = "/c convert " + drivename + "/fs:ntfs";//执行的命令
            //设置共享
            p.StartInfo.Arguments = " /c net share " + shareName + "=" + sharePath;//执行的命令
            p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//窗口状态为隐藏
            p.StartInfo.CreateNoWindow = true;//启动进程不创建窗口
            p.StartInfo.UseShellExecute = false;//从可执行文件创建进程
            p.StartInfo.RedirectStandardOutput = true;//将输出写入流中                
            p.Start();//启动进程
            p.WaitForExit(); 
 Process p = new Process();//创建进程对象
            p.StartInfo.FileName = "cmd.exe";//启动进程名称
            ///System.Environment.UserName    当前登录用户
            p.StartInfo.Arguments = "/c net localgroup administrators |find "%username%"";//执行的命令
            p.StartInfo.UseShellExecute = false;//从可执行文件创建进程
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;//窗口状态为隐藏
            p.Start();//启动进程
            return p.StandardOutput.ReadToEnd();
 ProcessStartInfo ps = new ProcessStartInfo();//实例化
            ps.FileName = "shutdown.exe";//执行的命令名
            ps.Arguments = "-r -t 1";// 重启计算机
 ps.Arguments = "-s -t 1";//关闭计算机
            ps.CreateNoWindow = true;
            ps.RedirectStandardError = true;
            ps.RedirectStandardInput = true;
            ps.RedirectStandardOutput = true;
            Process.Start(ps);//启动进程
原文地址:https://www.cnblogs.com/wjshan0808/p/4233688.html