在wcf rest服务中运行windows命令
我有一个运行以下代码的wcf rest服务:在wcf rest服务中运行windows命令,wcf,security,rest,command-line,process,Wcf,Security,Rest,Command Line,Process,我有一个运行以下代码的wcf rest服务: string command = @"C:\Test.exe"; System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command); Logger.Write(string.
string command = @"C:\Test.exe";
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
Logger.Write(string.Format("1"), LogType.Error);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
Logger.Write(string.Format("2"), LogType.Error);
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
Logger.Write(string.Format("3"), LogType.Error);
proc.Start();
Logger.Write(string.Format("4"), LogType.Error);
string result = proc.StandardOutput.ReadToEnd();
Logger.Write(string.Format("5"), LogType.Error);
// Display the command output.
Logger.Write(string.Format("Plugin : {0} has started", result), LogType.Error);
它在我的开发机器中运行良好。当我将服务发布到服务器时,问题就出现了。我的日志文件中的最新日志由以下人员编写:
Logger.Write(string.Format("4"), LogType.Error);
我认为这是一个安全/许可问题。我该怎么做才能在服务器上运行代码而不会出现问题呢
提前感谢,不知道或需要其他信息吗/您是否尝试在相关代码周围添加一个try-catch并保存异常信息?我有一个try-catch,但它不会在@RQDQ抛出异常。奇怪的是,通过浏览器对web服务的请求没有结束。这是自托管的还是在IIS下?什么操作系统?您的服务运行的凭据是什么?@Darrel Miller它在IIS下运行,操作系统是Win Server 2003。WindowsIdentity.GetCurrent.Name;给我一个网络用户。