public bool runAcmd(string strCmd, string strCmdWorkDir)
{
// "strCmd" can contain command line arguments
bool returnVal = true;
Process prcs;
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "cmd";
psi.Arguments = " /c " + strCmd;
psi.WorkingDirectory = strCmdWorkDir;
psi.WindowStyle = ProcessWindowStyle.Hidden;
try
{
prcs = Process.Start(psi);
// wait value is in milliseconds
if (!prcs.WaitForExit(10000))
returnVal = false;
}
catch (Exception ex)
{
returnVal = false;
}
finally
{
// Some lines of code to execute in
// case of error or not, if necessary
}
return returnVal;
}
No comments:
Post a Comment