C# 코드 내에서 실행 파일 (installPrint.exe)을 시작해야합니다. 이 목적을 위해 System.Diagnostics.Process 클래스를 사용했습니다. exe 파일은 프린터 드라이버를 설치하고 여러 파일을 다른 디렉토리에 복사합니다. 명령 줄에서 exe를 실행할 수 있으며 모든 것이 잘 작동합니다. 하지만 C# 응용 프로그램에서 Process 클래스로 파일을 실행하면 프린터 드라이버가 설치되지 않습니다.프린터 드라이버를 설치하는 C#의 프로세스를 어떻게 실행합니까?
Windows XP SP2 x86 컴퓨터에서 관리 사용자로 C# 응용 프로그램을 시작합니다. 내 실행 파일이 C# 응용 프로그램의 컨텍스트에서 작동하지 않는 이유는 무엇입니까? 내가 할 수있는 가능성은 무엇입니까?
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "-i \"My Printer\" -dir . -port myPort -spooler";
startInfo.CreateNoWindow = true;
startInfo.FileName = @"C:\Printer\install.exe";
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
//startInfo.Verb = "runas";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.WorkingDirectory = @"C:\Printer\";
session.Log("Working Directory: " + startInfo.WorkingDirectory);
session.Log("Executing " + startInfo.FileName);
try
{
Process process = new Process();
//process.EnableRaisingEvents = false;
process.StartInfo = startInfo;
process.Start();
session.Log("installer.exe started");
StreamReader outReader = process.StandardOutput;
StreamReader errReader = process.StandardError;
process.WaitForExit();
//session.Log(outReader.ReadToEnd());
//session.Log(errReader.ReadToEnd());
session.Log("RETURN CODE: " + process.ExitCode);
}
catch (Exception ex)
{
session.Log("An error occurred during printer installation.");
session.Log(ex.ToString());
}
예외가 있습니까? 오류가 있습니까? – Saint
프린터 드라이버를 추가 할 수 없다는 정보 만받습니다. 또한 설치 프로그램은 로컬 프린터 포트를 만듭니다. 이것은 잘 작동하지만 프린터를 추가 할 때는 실패합니다. – CubaLibre
실패했습니다. 나는 setCreateNoWindow = false를 사용하고 쉘을 사용하고 이제는 작동한다. – CubaLibre