Process.Start("C://WINDOWS//system32//shutdown.exe -s -t 100");  怎么不行啊???

解决方案 »

  1.   


    Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
      

  2.   

    解决了,应该这样 Process.Start("C://WINDOWS//system32//cmd.exe","/c shutdown.exe -s -t 100");
      

  3.   

    这样行么?
    System.Diagnostics.Process.Start("c:\\windows\\system32\\shutdown.exe", "-s -t 100"); 
      

  4.   

    System.Diagnostics.Process.Start("c:\\windows\\system32\\shutdown.exe", "-s -t 100"); 
    可以这样用,等待关机呢,555555~~~~
      

  5.   

    可以用一种比较灵活的方式来做:private void btnExecute_Click(object sender, EventArgs e)
            {
                tbResult.Text = "";
                ProcessStartInfo start = new ProcessStartInfo("Ping.exe");//设置运行的命令行文件问ping.exe文件,这个文件系统会自己找到
                //如果是其它exe文件,则有可能需要指定详细路径,如运行winRar.exe
                start.Arguments = txtCommand.Text;//设置命令参数
                start.CreateNoWindow = true;//不显示dos命令行窗口
                start.RedirectStandardOutput = true;//
                start.RedirectStandardInput = true;//
                start.UseShellExecute = false;//是否指定操作系统外壳进程启动程序
                Process p=Process.Start(start);
                StreamReader reader = p.StandardOutput;//截取输出流
                string line = reader.ReadLine();//每次读取一行
                while (!reader.EndOfStream)
                {
                    tbResult.AppendText(line+" ");
                    line = reader.ReadLine();
                }
                p.WaitForExit();//等待程序执行完退出进程
                p.Close();//关闭进程
                reader.Close();//关闭流
            }
      

  6.   

     C#中运行命令行截取输出流的例子
    说明:经常有朋友问如何在C#中运行一个dos命令,并截取输出、输出流的问题,这个问题我以前在Java中实现过,由于在C#中没有遇到过类似的 情况,为了避免每次别人问都要一遍一遍演示的情况,特地做了一个简单的例子,实现在WinForm中ping一个网站,并且将ping的结果显示在一个文本框中。这是动态指定参数,运行截图如下:
      

  7.   

    用这个API函数BOOL ExitWindowsEx(
      UINT uFlags,
      DWORD dwReason
    );
      

  8.   


    哈哈 ^_^幸好100s 赶紧打开cmd输入shutdown -a 就取消关机了