fjfjfjfjfjfj

【.Net】执行CMD命令

                Process proc = new Process();
                proc.StartInfo.FileName = "cmd.exe";
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.RedirectStandardInput = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.CreateNoWindow = true;
                proc.Start();

                string commandLine;
                if (isCancel)
                    commandLine = @"shutdown /a";
                else
                    commandLine = @"shutdown /f /s /t " + interval.ToString();
                proc.StandardInput.WriteLine(commandLine);


以执行关机为例。

posted on 2013-09-19 12:50  撬棍  阅读(184)  评论(0编辑  收藏  举报

导航