internal void RunProcess(string fileNameCMD, string arguments, string logFileName, string processType)
        {
            ProcessStartInfo runStartInfo = new ProcessStartInfo();

            //Inject and ClearKey processes doesn't use the .\OA3\ working directory (run AFUWINx64.EXE)                                                                                                      IS THIS NEEDED?
            if (!(processType == "inject" || processType == "clearKey"))
            {
                runStartInfo.WorkingDirectory = @".\OA3\";
            }
            runStartInfo.FileName  = fileNameCMD;
            runStartInfo.Arguments = arguments;
            Process runProcess = new Process();

            runProcess.StartInfo = runStartInfo;
            runProcess.StartInfo.UseShellExecute        = false;
            runProcess.StartInfo.RedirectStandardInput  = true;
            runProcess.StartInfo.RedirectStandardOutput = true;
            runStartInfo.CreateNoWindow = true;

            runProcess.Start();
            //runProcess.WaitForExit();

            string outputString = "\r\n" + fileNameCMD + " " + arguments + "\r\n\r\n";

            while (!runProcess.StandardOutput.EndOfStream)
            {
                outputString += runProcess.StandardOutput.ReadLine() + "\r\n";
            }

            runProcess.Close();
            string newPath = _OutputPath + @"\Logs" + logFileName;

            pa.moveTextToFile(newPath, outputString, processType);
        }
Esempio n. 2
0
        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();
        }