Process Worker Web Service (.exe Starter)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Diagnostics;
using System.Security.Principal;
using System.Security;
using System.Runtime.InteropServices;

namespace ProWS
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class Pro: System.Web.Services.WebService

        public bool ProWorker(string filePath)

            string htm = ".htm";
            string iFileName = Path.GetFileName(filePath);
            string oFileName = iFileName.Substring(0, iFileName.IndexOf(htm));
            string newFilePath = filePath.Substring(0, filePath.IndexOf(iFileName));

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow = true;
                startInfo.UseShellExecute = false;
                //.xls dosyanın nereye kaydedileceği burada belirtilmelidir.
                //startInfo.WorkingDirectory = "D:\\XXX\\temp\\";
                startInfo.WorkingDirectory = "C:\\ XXX \\temp\\";
                //Rep2excel.exe dosyası proje dosyları arasına kopyalanmalıdır.
                startInfo.FileName = Server.MapPath(" XXX .exe");
                startInfo.RedirectStandardError = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.Arguments = "-i:" + newFilePath + iFileName + " -o:" + "C:\\XXX\\temp\\" + oFileName + ".xls";

                using (Process process = Process.Start(startInfo))
                    //if (process.ExitCode == 0) { }
                    return true;

            catch (Exception e)
                return false;




Popular posts from this blog

Fix for "Websites cannot be started unless both the Windows Activation Service (WAS) and the World Wide Web Publishing Service (W3SVC) are running, Both services are currently stopped"

Solution for "Can not obtain Oracle client information from registry"

How to specify proxy credentials in web.config