Webservice to call a batch file?

Discussion in 'ASP .Net Web Services' started by Lee Franke, Dec 11, 2006.

  1. Lee Franke

    Lee Franke Guest

    I've written a small webservice that all it does is call a batch file on the
    server passing along some parameters.

    It seems that the batch file (sm.cmd) exits after only executing for a
    second or two.

    Here is the code

    private string CallExecutable(string Path, string Arguments)
    {
    string sReturn = "";
    try
    {
    Process proc = new Process();
    if(File.Exists(Path))
    {
    //proc.StartInfo = new
    ProcessStartInfo(ConfigurationSettings.AppSettings["ExecutablePath"].ToString(),
    "buildspecs." + sBuildSpec);
    proc.StartInfo.FileName = Path;
    proc.StartInfo.Arguments = Arguments;
    //proc.StartInfo.CreateNoWindow = false;
    proc.StartInfo.UseShellExecute = true;
    //proc.Exited += new EventHandler(OnExited);
    //proc.EnableRaisingEvents = true;

    bool bTest = proc.Start();
    proc.WaitForExit(9000);
    proc.Dispose();
    sReturn = bTest.ToString();
    }
    else
    sReturn = "Executable does not exist";

    }
    catch(Exception ex)
    {
    sReturn = ex.Message;
    }
    return sReturn;


    }




    I've tried increasing the time on teh WaitForExit, I've also tried leaving
    it blank so that it waits until completetion.

    The reason I know it exits after briefly executing is that a log is written
    by sm.cmd and it only shows a small bit of processing.

    Any ideas on how to fix this?



    thanks,

    lee
     
    Lee Franke, Dec 11, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luc The Perverse

    Compilation Batch File Won't Pipe To File

    Luc The Perverse, Oct 22, 2005, in forum: Java
    Replies:
    7
    Views:
    4,907
    Roedy Green
    Oct 23, 2005
  2. Cyril
    Replies:
    2
    Views:
    4,510
    Cyril
    Jun 1, 2006
  3. ranga

    how to call webmethods in a batch

    ranga, Jan 3, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    121
    Dino Chiesa [Microsoft]
    Jan 5, 2005
  4. ranga

    how to make webservice calls in a batch

    ranga, Jan 3, 2005, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    162
    ranga
    Jan 4, 2005
  5. René Preußler

    Asynchronous Call of WebService method within a WebService

    René Preußler, Oct 29, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    198
    René Preußler
    Oct 29, 2008
Loading...

Share This Page