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
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