private static bool createUser(String batchFileName, String userName)
{
bool retVal = true;
try
{
var dir = AppDomain.CurrentDomain.BaseDirectory;
var fileName = Path.Combine(dir, batchFileName);
Process proc = new Process
{
StartInfo =
{
FileName = fileName,
WorkingDirectory = dir,
Arguments = userName,
UseShellExecute = true
}
};
proc.Start();
proc.WaitForExit();
int exitCode = proc.ExitCode;
proc.Close();
retVal = (exitCode == 0);
if (!retVal)
{
MessageBox.Show("Could not create user.\nThe batch file " + fileName + " returned an error.\n\nPlease run this batch file manually to check the reason", "ACAT Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("Unable to create user. Error executing batchfile " + batchFileName + ".\nError: " + ex.ToString());
retVal = false;
}
return retVal;
}