C# 如何调用rundll32.exe
问题如下,请各位大大指点迷津我想用C#调用系统自带的rundll32.exe, 来完成网络打印机的安装,具体命令如下:
C:\Windows\System32\rundll32 C:\Windows\SysWOW64\printui.dll,PrintUIEntry /if /b "BasePrinterName" /f absolutePath\driver.INF /r "PortName" /m "DriverModelName" /z
命令可以在cmd窗口下正常执行,但是如下代码会抛出错误“系统找不到指定的文件”:
------------------------------------------------------------------------------------------------------------------------------------------------------
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Windows\System32\rundll32 C:\Windows\SysWOW64\printui.dll,PrintUIEntry /if /b ""BasePrinterName"" /f " + Application.StartupPath + @"\Path\driver.INF /r ""PortName"" /m ""DriverModelName"" /z";
proc.StartInfo.Arguments = "";
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start(); // 抛错代码
proc.WaitForExit();
------------------------------------------------------------------------------------------------------------------------------------------------------