问题描述
如何启动 另一台机器 c#?
我正在尝试在另一台机器上启动打印过程。我甚至在同一台机器上提供了用户名和密码。我作为服务运行时遇到Access拒绝问题。由于应用程序打印过程有效。
private void PrintFile( string sFileName, string sPrinter)
{
string sArgs = / t \ + sFileName + \\ + sPrinter + \;
System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = System.Configuration.ConfigurationManager.AppSettings [ AcrobatExePath]。ToString ();
startInfo.Arguments = sArgs;
startInfo.CreateNoWindow = true ;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = Process.Start(startInfo);
proc.WaitForExit( 60000 ); // 等待最多10秒才能完成流程
if (!proc.HasExited)
{
proc.Kill();
proc.Dispose();
}
}
我的尝试:
private void PrintFile(string sFileName,string sPrinter)
{
string sArgs = / t \+ sFileName +\\+ sPrinter +\;
System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = System.Configuration.ConfigurationManager.AppSettings [AcrobatExePath]。ToString();
startInfo.Arguments = sArgs;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = Process.Start(startInfo);
proc.WaitForExit(60000); //完成整个过程最多等待10秒
if(!proc.HasExited)
{
proc.Kill() ;
proc.Dispose();
}
}
How to start a process in another machine in c#?
I am trying to start a print process in another machine. i even gave the username and password in the same machine. I am getting Access denied issue while running as service.As application print process works.
private void PrintFile(string sFileName, string sPrinter) { string sArgs = " /t \"" + sFileName + "\" \"" + sPrinter + "\""; System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["AcrobatExePath"].ToString(); startInfo.Arguments = sArgs; startInfo.CreateNoWindow = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; System.Diagnostics.Process proc = Process.Start(startInfo); proc.WaitForExit(60000); // Wait a maximum of 10 sec for the process to finish if (!proc.HasExited) { proc.Kill(); proc.Dispose(); } }
What I have tried:
private void PrintFile(string sFileName, string sPrinter)
{
string sArgs = " /t \"" + sFileName + "\" \"" + sPrinter + "\"";
System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["AcrobatExePath"].ToString();
startInfo.Arguments = sArgs;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = Process.Start(startInfo);
proc.WaitForExit(60000); // Wait a maximum of 10 sec for the process to finish
if (!proc.HasExited)
{
proc.Kill();
proc.Dispose();
}
}
这篇关于如何在C#中的另一台机器上启动进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!