ACAT.Applications.ACATApp.Program.createUser C# (CSharp) Method

createUser() private static method

Creates the specified user using the batchFileName. Executes the batchfile which creates the user folder and copies the initialization files
private static createUser ( String batchFileName, String userName ) : bool
batchFileName String Name of the batchfile to run
userName String Name of the user
return bool
        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;
        }