//cmd:"regsvr32 " + dllPath(注册dll的语句)
//output:string.Empty(注册后的反馈信息 )
private static void runCmd(string cmd, out string output)
{
string CmdPath = @"C:\Windows\System32\cmd.exe";
cmd = cmd.Trim().TrimEnd('&') + "&exit";//说明:不管命令是否成功均执行exit命令,否则当调用ReadToEnd()方法时,会处于假死状态
using (Process p = new Process())
{
p.StartInfo.FileName = CmdPath;
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = true; //接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true; //由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true; //重定向标准错误输出
p.StartInfo.CreateNoWindow = true; //不显示程序窗口
p.Start();//启动程序
//向cmd窗口写入命令
p.StandardInput.WriteLine(cmd);
p.StandardInput.AutoFlush = true;
//获取cmd窗口的输出信息
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();//等待程序执行完退出进程
p.Close();
}
}

最新文章

  1. 【Oracle 集群】Linux下Oracle RAC集群搭建之Oracle DataBase安装(八)
  2. MySQL 主从复制
  3. [游戏开发-学习笔记]菜鸟慢慢飞(四)-Camera
  4. caffe源码解析
  5. 用SQL语句创建四个表并完成相关题目-10月18日更新
  6. 分享一个 @user 前端插件
  7. hadoop2.6---windows下开发环境搭建
  8. Windows下Memcache的安装与在php中使用
  9. batch 数字进制的问题
  10. 开发备必:WEB前端开发规范文档
  11. Codeforces 161D Distance in Tree
  12. img图片标签alt和title属性的区别
  13. 要不要用gzip优化前端项目
  14. NSRC技术分享——自制Linux Rootkit检测工具
  15. 如何看MySql执行计划explain(或desc)
  16. js返回值 数组去重
  17. 使用Spark下的corr计算皮尔森相似度Pearson时,报错Can only zip RDDs with same number of elements in each partition....
  18. 下载并安装oracle 11g客户端
  19. AndroidStudio+ideasmali动态调试smali汇编
  20. centos7 更改主机名

热门文章

  1. java实现spark常用算子之count
  2. 帝国cms 【反馈案例】 代码
  3. 独热编码 pandas get_dummies
  4. 89. Gray Code (Java)
  5. 11、Nginx反向代理服务
  6. linux服务器上软件的安装
  7. 阿里云(ecs服务器)使用1-设置安全组
  8. java基础笔试题一
  9. pikachu-file
  10. web性能优化-浏览器渲染原理