Webservice to call a batch file?

L

Lee Franke

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,538
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top