Thursday, June 4, 2015

asp.net call exe from web application

 Process p1 = new Process();
            try
            {
                //p1.StartInfo.WorkingDirectory = "C:\\Inetpub\\wwwroot"; //sets the working directory in which the exe file resides
                p1.StartInfo.WorkingDirectory = "C:\\Users\\shekhar\\Desktop\\ScanUtility"; //sets the working directory in which the exe file resides
                p1.StartInfo.FileName = "ScanUtility.exe";   // actual file name
                p1.StartInfo.Arguments = "D:\\Temp\\Pic_{0}";//arguments here i had taken hello as first argument and Murali as second argument and splited them in exe file
                p1.Start();
                p1.WaitForExit();
                if (p1.HasExited) p1.Dispose();
                else
                {
                    p1.Kill();
                }

            }
            catch (Exception e1) { e1.Message.ToString(); }

1 comment: