C# 在iis服务器上从web api运行exe文件不工作
我想在收到用户请求时在Web API上执行一个exe文件。它工作得很好,但当我将web API托管到服务器时,当用户请求到来时,exe文件不会执行。如何从IIS服务器上的web API执行exe文件 以下是流程启动代码:C# 在iis服务器上从web api运行exe文件不工作,c#,asp.net-web-api,C#,Asp.net Web Api,我想在收到用户请求时在Web API上执行一个exe文件。它工作得很好,但当我将web API托管到服务器时,当用户请求到来时,exe文件不会执行。如何从IIS服务器上的web API执行exe文件 以下是流程启动代码: public static void Start(long campaign_id, long contact_id, string startDate, string endDate, string user) { try { //Window
public static void Start(long campaign_id, long contact_id, string startDate, string endDate, string user)
{
try
{
//WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.WorkingDirectory = @"C:\";
startInfo.Arguments = "/c sparkclr-submit --master " + ConfigurationManager.AppSettings["SparkMaster"] + " --driver-class-path " + AppDomain.CurrentDomain.BaseDirectory + "Engine\\mysql.jar " + "--exe CmAnalyticsEngine.exe " + AppDomain.CurrentDomain.BaseDirectory + "Engine " + campaign_id + " " + contact_id + " " + startDate + " " + endDate + " " + user;
process.StartInfo = startInfo;
process.Start();
}
catch (Exception e)
{
LogWritter.WriteErrorLog(e);
}
}
如何启动exe?你有错误日志吗 您可以尝试在
进程中使用动词运行方式
。启动
以管理员身份执行exe文件
ProcessStartInfo proc = new ProcessStartInfo();
proc.WindowStyle = ProcessWindowStyle.Normal;
proc.FileName = myExePath;
proc.CreateNoWindow = false;
proc.UseShellExecute = false;
proc.Verb = "runas"; //this is how you pass this verb
您必须为iis用户授予执行权限。我已为iis用户授予包含exe文件的目录和应用程序池的权限,但仍然没有working@Milhail怎么做我需要用process.start()传递参数?我已经试着让这个动词作为run,但仍然没有输出,感谢您尝试运行x64的应用程序?