private void Button_Click(object sender, RoutedEventArgs e) { //применяем твики для которых посталены чекбоксы for (int i = 0; i < count; i++) { bool isChecked = (bool)checks[i].IsChecked; if (isChecked) { TBox.AppendText(regTweaks[i].SaveNewValue()); if (regTweaks[i].CmdExist) { //запуск процесса с смд Process cmd = new Process(); cmd.StartInfo.FileName = "cmd.exe"; //cmd.StartInfo.Arguments = "/C " + regTweaks[i].Cmd; cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.UseShellExecute = false; cmd.Start(); cmd.StandardInput.WriteLine("/C " + regTweaks[i].Cmd); cmd.StandardInput.Flush(); cmd.StandardInput.Close(); cmd.WaitForExit(); TBox.AppendText(cmd.StandardOutput.ReadToEnd()); } } } }
private void MainWindow_Loaded(object s, RoutedEventArgs e) { for (int i = 0; i < count; i++) // цикл для создания визуальнх компоненнтов { TBox.AppendText(inifiles[i] + "\n"); regTweaks[i] = ReadiniFile(inifiles[i]); //заполнение массива с твиками tbarray[i] = new TextBlock { Text = regTweaks[i].Name + "\t" }; //заполнение массива с текстблоками checks[i] = new CheckBox { Margin = new Thickness(5, 5, 5, 5) }; //заполнение массива с чекбоксами if (regTweaks[i].ValueExist) { if (regTweaks[i].NewValue.ToString() != regTweaks[i].KeyValue.ToString()) { checks[i].IsChecked = true; tbarray[i].Text += regTweaks[i].ValueName; } else { checks[i].IsEnabled = false; tbarray[i].Text += "уже выполнено"; } } else { checks[i].IsChecked = true; tbarray[i].Text += "не найдено"; } stackpan1.Children.Add(tbarray[i]); stackpan1.Children.Add(checks[i]); } //System.IO.Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName); //имя без расширения //System.Environment.GetCommandLineArgs()[0];// полный путь }