如何在程序中,或者在安装部署中执行驱动程序的安装?

ThunderLight 2008-06-23 02:25:34
例如有一个驱动程序 aa.inf 需要安装到电脑
如何在c#代码中安装 ?
或者如何在安装部署项目中安装?




string a="Rundll32.exe setupapi.dll";
string b = " InstallHinfSection DefaultInstall 132 c:\\aa.inf";

第一次尝试
System.Diagnostics.Process.Start(a,b); 提示系统找不到指定文件

第2次尝试
System.Diagnostics.Process.Start(a+b); 提示系统找不到指定文件

第三次尝试:

string installCmdLine = " rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 c:\\aa.inf";

System.Diagnostics.Process.Start(installCmdLine ); 提示系统找不到指定文件


但是后者是可以在命令行实现的,那么到底怎么做呢?
谢谢




...全文
241 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tigerworm 2011-09-09
  • 打赏
  • 举报
回复
你可以用cmd.exe来转一下,也可以用Rundll32.exe直接整,给你个CMD的
string strOutput = string.Empty;
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WorkingDirectory = "C:";
p.Start();
p.StandardInput.WriteLine("rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 C:\\aaaaaaaaaa.inf");
p.WaitForExit(3000);
p.StandardInput.WriteLine("exit");
while (!p.StandardOutput.EndOfStream)
{
strOutput = p.StandardOutput.ReadLine();
Console.WriteLine(strOutput);
}
p.Close();
p.Dispose();
lsj_zrp 2008-06-27
  • 打赏
  • 举报
回复
遇到这样的我一般使用RAR压缩成EXE,在压缩的时候设置解压后或解压前执行什么文件
ThunderLight 2008-06-27
  • 打赏
  • 举报
回复
顶一下
zhouchunping_99 2008-06-27
  • 打赏
  • 举报
回复
把你的驱动程序放在..\bin\Debug下,
然后
System.Diagnostics.Process.Start("aa.inf");

或者
System.Diagnostics.Process.Start("c:\....\aa.inf");
其中:c:\....\aa.inf 指的是绝对路径。
wzq6511 2008-06-27
  • 打赏
  • 举报
回复
wzq6511 2008-06-27
  • 打赏
  • 举报
回复
把驱动的安装放到自定义操作里面。
zhmvb 2008-06-27
  • 打赏
  • 举报
回复
string a="Rundll32.exe setupapi.dll";
string b = " InstallHinfSection DefaultInstall 132 c:\\aa.inf";

不太明白 “InstallHinfSection DefaultInstall 132 “ 起什么作用。
或者你试一下把 "Rundll32.exe" 的地址写成绝对地址试一下,比如 "c:\window\system32\Rundll32.exe setupapi.dll"
QQQQAnnie 2008-06-23
  • 打赏
  • 举报
回复
不明白,没用过




回复内容太短了!

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧