Şu kodlarımda ben bir checboxa birden fazla batch kodu eklettirmekiistiyorum using System.IO;
using System.Collections.Generic;
using Microsoft.Win32;
using Microsoft.Dism;
using System.Text.Json;
using ShadesToolkit.ViewModels.Pages;
using Wpf.Ui.Controls;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Windows.Media;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using System.Text;
using System.Windows.Controls;
using TreeViewItem = System.Windows.Controls.TreeViewItem;

namespace ShadesToolkit.Views.Pages
{
    public partial class ExtraDebloat : INavigableView<ExtraDebloatViewModel>
    {
        private string MountFolder = Path.Combine(Path.GetTempPath(), "MountFolder");

        public ExtraDebloatViewModel ViewModel { get; }
        private readonly Dictionary<CheckBox, string> checkBoxScripts = new Dictionary<CheckBox, string>();
        public ExtraDebloat(ExtraDebloatViewModel viewModel)
        {
            ViewModel = viewModel;
            DataContext = this;

            InitializeComponent();
            checkBoxScripts.Add(OneDrive, "MinSudo.exe --TrustedInstaller --Verbose --WorkDir=\"\" cmd /c \"del /S /Q \"%InstallDir%\\*OneDrive*\"\"");
            checkBoxScripts.Add(OneDrive, "MinSudo.exe --TrustedInstaller --Verbose --WorkDir=\"\" cmd /c \"del /S /Q \"%InstallDir%\\*onedrive-backup*\"\"");
            checkBoxScripts.Add(iki, "echo Batch Script 2");
            checkBoxScripts.Add(uc, "echo Batch Script 3");
            checkBoxScripts.Add(dort, "echo Batch Script 4");
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder scriptContent = new StringBuilder();

            // Bat dosyasının en başına "echo off" ekler
            scriptContent.AppendLine("@echo off");
            scriptContent.AppendLine("set InstallDir=C:\\Users\\%USERNAME%\\AppData\\Local\\Temp\\MountFolder");

            // Her bir TreeViewItem için işleme
            foreach (TreeViewItem treeViewItem in treeView.Items)
            {
                ProcessTreeViewItem(treeViewItem, scriptContent);
            }

            if (scriptContent.Length > "@echo off".Length + Environment.NewLine.Length)
            {
                SaveScriptToFile(scriptContent.ToString());
            }
            else
            {
                MessageBox.Show("Hiçbir komut seçilmedi.");
            }
        }

        private void ProcessTreeViewItem(ItemsControl itemsControl, StringBuilder scriptContent)
        {
            foreach (object obj in itemsControl.Items)
            {
                TreeViewItem subItem = itemsControl.ItemContainerGenerator.ContainerFromItem(obj) as TreeViewItem;

                if (subItem != null)
                {
                    // Alt TreeViewItem’ı işle
                    ProcessTreeViewItem(subItem, scriptContent);
                }

                CheckBox checkBox = obj as CheckBox;
                if (checkBox != null && checkBox.IsChecked == true)
                {
                    string script;
                    if (checkBoxScripts.TryGetValue(checkBox, out script))
                    {
                        // CheckBox’a karşılık gelen batch komutunu sözlükten al ve ekleyebiliriz.
                        scriptContent.AppendLine(script);
                    }
                }
            }
        }

        private void SaveScriptToFile(string content)
        {
            string filePath = "tweaker.bat";
            File.WriteAllText(filePath, content);
            MessageBox.Show(filePath + " kaydedildi.");
        }
    }
}