Reputation: 382
I want to execute an exe file on to The Web API as and when user request comes. It is working perfectly but when I am hosting web API to server the exe file is not executed when user request comes. What to do for executing the exe file from web API on IIS server?
Here is the process starting code:
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);
}
}
Upvotes: 2
Views: 2423
Reputation: 4138
How are you starting the exe? You have any error logs?
You can try using the verb runas
in Process.Start
to execute the exe file as an Administrator.
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
Upvotes: 2