private void RunOA3() { OA3_Action oaAction = new OA3_Action(); if (ValidateForm(this)) { oaAction._ReplaceSku = gbOsRadio.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name.ToString(); oaAction._SelectedMotherBoardText = gbMB.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Text; oaAction._ReplaceModel = _boxxFamily; oaAction._OutputPath = _OutputPath; oaAction.CreateConfigXml(); oaAction._OA3ToolPath = _OA3ToolPath; if (cbDefaultKey.Checked) { oaAction.DefaultKey(); } oaAction.Assemble(); oaAction._DriveLetter = _MappedDrive; oaAction._SerialNumber = _SerialNumber; oaAction.Inject(); //oaAction.Validate(); //oaAction.Report(); //close all programs and restart the computer Restart(); } }
private void BtnDefault_Click(object sender, EventArgs e) { if (ValidateForm(this)) { OA3_Action oaAction = new OA3_Action(); oaAction._OutputPath = _OutputPath; oaAction.DefaultKey(); } }
private void BtnClearKey_Click(object sender, EventArgs e) { if (ValidateForm(this)) { OA3_Action oaAction = new OA3_Action(); oaAction._SelectedMotherBoardText = gbMB.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Text; oaAction._OutputPath = _OutputPath; oaAction._DriveLetter = _MappedDrive; oaAction.ClearKey(); //close all programs and restart the computer Restart(); } }
private void RerunOA3() { OA3_Action oaAction = new OA3_Action(); oaAction._OutputPath = _OutputPath; //oaAction._SelectedMotherBoardText = gbMB.Controls.OfType<RadioButton>().FirstOrDefault(r => r.Checked).Text; //oaAction.ClearKey(); if (!(Directory.Exists(_OutputPath + @"\Logs"))) { Directory.CreateDirectory(_OutputPath + @"\Logs"); } //TODO condense this 1/17/18 string[] filesArray = Directory.GetFiles(_OutputPath); List <string> fileNameArray = new List <string>(); foreach (string fullPath in filesArray) { string fileName = Path.GetFileName(fullPath); try { string from = System.IO.Path.Combine(fullPath); string to = System.IO.Path.Combine(_OutputPath + @"\Logs\" + fileName); File.Move(from, to); fileNameArray.Add(to); } catch (IOException ex) { Console.WriteLine(ex); } } foreach (string fullFilePath in fileNameArray) { string fileName = Path.GetFileName(fullFilePath); string directory = Path.GetDirectoryName(fullFilePath); string outputString = ""; string line; try { //After file move, append txt to already existing file if exists & rename .bin file with timestamp if (Path.GetFileName(fullFilePath) != "OA3.bin") { StreamReader reader1 = new StreamReader(fullFilePath); while ((line = reader1.ReadLine()) != null) { outputString += line + "\r\n"; } reader1.Close(); File.Delete(fullFilePath); string outputPath = directory + @"\" + fileName + "_OA3Log.txt"; Process_Action pa = new Process_Action(); pa.moveTextToFile(outputPath, outputString, "moveFiles"); } else { string newFileName = directory + @"\" + fileName + "_" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Year.ToString() + " Time_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Millisecond.ToString() + Path.GetExtension(fileName); File.Move(fullFilePath, newFileName); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } //oaAction.DefaultKey(); }
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(); } } }