Vivek Chandraprakash
Vivek Chandraprakash

Reputation: 1163

Executing exe from asp page

i have an exe file that does some pdf processing. i would like to call this exe within an asp page and i want the asp page to wait until the exe has completed processing. any solution?

thanks -Vivek

Upvotes: 3

Views: 2543

Answers (2)

Mohammad Karimi
Mohammad Karimi

Reputation: 4223

public ActionResult RunReport()
        {
            //Set this page timeout
            HttpContext.Server.ScriptTimeout = int.MaxValue;

            var psi = new ProcessStartInfo()
            {
                //Arguments = string.Format("/k \"\"Test.exe\" \"{0}\" \"{1}\" \"{2}\"\"", arg1, arg2, arg3),
                CreateNoWindow = false,
                UseShellExecute = true,
                WorkingDirectory = @"C:\Test",
                FileName = "Test.exe"
            };

            using (var process = Process.Start(psi))
            {
                process.WaitForExit(int.MaxValue);
            }

            return RedirectToAction("Index");
        }

Upvotes: -1

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171411

Set WshShell = WScript.CreateObject("WScript.Shell")
intReturn = WshShell.Run(Server.MapPath("PathToMyApp.exe"), 1, TRUE)

Upvotes: 3

Related Questions