Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   Webservice to call a batch file? (http://www.velocityreviews.com/forums/t786789-webservice-to-call-a-batch-file.html)

Lee Franke 12-11-2006 07:05 PM

Webservice to call a batch file?
 
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




All times are GMT. The time now is 10:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.