public FrmMain(string outputPath, string driveLetter, string function) { WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); if (!principal.IsInRole(WindowsBuiltInRole.Administrator)) { MessageBox.Show("The program must be run as Admin" + Environment.NewLine + Environment.NewLine + "Please restart the program" + Environment.NewLine + Environment.NewLine + "If clearKey or injection process has already started. A batch file has been created on the server"); ErrorAndExit("The program must be run as Admin" + Environment.NewLine + Environment.NewLine + "Please restart the program" + Environment.NewLine + Environment.NewLine + "If clearKey or injection process has already started. A batch file has been created on the server", "Allow to run as Administrator", "No Admin Privileaes Allowed"); } else { try { SetCurrentDirectory(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (function == "injected") { driveLetter = driveLetter.Substring(0, 1); try { CheckNetworkPathAvailability("reboot"); _OA3ToolPath = ConfigurationManager.AppSettings["OA3toolPath"].ToString(); OA3_Action oaAction = new OA3_Action(); oaAction._OutputPath = outputPath; oaAction._OA3ToolPath = _OA3ToolPath; oaAction.Validate(); oaAction.Report(); FrmMain_Close("", null); } catch (Exception ex) { MessageBox.Show("Problem caught in frmMain()" + Environment.NewLine + Environment.NewLine + ex); } } else if (function == "clearKey") { SetCurrentDirectory(); InitializeComponent(); btnClearKey.Visible = false; string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\OA3ActivationScript.bat"; if (File.Exists(startUpFolderPath)) { File.Delete(startUpFolderPath); } startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\null"; if (File.Exists(startUpFolderPath)) { File.Delete(startUpFolderPath); } } else { InitializeComponent(); } } }