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