zoukankan      html  css  js  c++  java
  • 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);//启动进程
  • 相关阅读:
    GridView 应用貌似是个mm写的,值得尊敬!
    .net 时间函数
    .net 获取url的方法
    SaveGraphics
    asp网站页面上都是问号
    由于编码方式导致CSS样式表失效
    .net url乱码
    常用正则表达式
    解决realse版在加载toolbar后不正常退出的现象
    general error c1010070: Failed to load and parse the manifest
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/4233688.html
Copyright © 2011-2022 走看看