例如有一个驱动程序 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 ); 提示系统找不到指定文件
但是后者是可以在命令行实现的,那么到底怎么做呢?
谢谢
如何在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 ); 提示系统找不到指定文件
但是后者是可以在命令行实现的,那么到底怎么做呢?
谢谢
解决方案 »
- lable-textbox 随窗体变化而变化
- .net程序部署在XP上报错
- DataList中如何显示规定字数?
- DataGridView 读取数据时有错误
- WinForm中如何实现计划任务以及多线程
- 各位老兄,小弟要找个工作,请问c#程序员一般薪水能给多少?
- C#中如何添加Microsoft.DirectX引用?
- 急:SQL语句种时间的问题:AND DateTime.Compare(Dateandtime,2005-3-2 0:00:00)>0
- 高分请教:如何用c#将EXCEL数据加载到ORACLE数据库中?
- 现在市面上的盗版VS.NET 7.0正式版是否货真价实?有Enterprise版了吗?
- 怎样取消datagridview的默认选中单元格
- c# 字符串函数
string b = " InstallHinfSection DefaultInstall 132 c:\\aa.inf"; 不太明白 “InstallHinfSection DefaultInstall 132 “ 起什么作用。
或者你试一下把 "Rundll32.exe" 的地址写成绝对地址试一下,比如 "c:\window\system32\Rundll32.exe setupapi.dll"
然后
System.Diagnostics.Process.Start("aa.inf");或者
System.Diagnostics.Process.Start("c:\....\aa.inf");
其中:c:\....\aa.inf 指的是绝对路径。
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();