开发者

Running a windows command in a wcf rest service

I have a wcf rest service running the code below:

             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.For开发者_如何学Cmat("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);

It works fine in my development machine. When I publish the service to server, the problem occurs. The latest log in my log file is written by:

Logger.Write(string.Format("4"), LogType.Error);

I think it's a security / permission issue. What can I do to run my code without problem in server too.

Thanks in advance,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜