diff --git a/languages/de/Bloatynosy.resources.dll b/languages/de/Bloatynosy.resources.dll new file mode 100644 index 0000000..4bc3634 Binary files /dev/null and b/languages/de/Bloatynosy.resources.dll differ diff --git a/languages/ko/Bloatynosy.resources.dll b/languages/ko/Bloatynosy.resources.dll new file mode 100644 index 0000000..7425fa6 Binary files /dev/null and b/languages/ko/Bloatynosy.resources.dll differ diff --git a/src/Bloatynosy/JsonPluginHandler.cs b/src/Bloatynosy/JsonPluginHandler.cs new file mode 100644 index 0000000..92c5f8f --- /dev/null +++ b/src/Bloatynosy/JsonPluginHandler.cs @@ -0,0 +1,222 @@ +using Newtonsoft.Json; +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BloatynosyNue +{ + public class JsonPluginHandler + { + public string PlugID { get; set; } + public string PlugInfo { get; set; } + public string[] PlugCheck { get; set; } + public string[] PlugDo { get; set; } + public string[] PlugUndo { get; set; } + public string PlugCategory { get; set; } + + private Logger logger; + + public JsonPluginHandler(Logger logger) + { + this.logger = logger; + } + + public bool PlugCheckFeature() + { + bool isFeatureActive = true; + foreach (var command in PlugCheck) + { + if (!ExecuteCommandAndCheckResult(command)) + { + isFeatureActive = false; + break; + } + } + logger.Log($"Feature '{PlugID}' is {(isFeatureActive ? "active" : "inactive")}", System.Drawing.Color.Black); + return isFeatureActive; + } + + // PlugCheck Helper to execute commands and check the result + private bool ExecuteCommandAndCheckResult(string command) + { + try + { + var process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "cmd.exe", + Arguments = $"/c {command}", + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true, + } + }; + process.Start(); + process.WaitForExit(); + + // Read the output of the command + string output = process.StandardOutput.ReadToEnd(); + + // Check if output contains "1" (indicating active) or "0" (indicating inactive) + bool isActive = output.Contains("1"); + + // logger.Log($"Plugin executed successfully: {command}. Result: {(isActive ? "active" : "inactive")}", System.Drawing.Color.Black); + return isActive; + } + catch (Exception ex) + { + logger.Log($"Error executing plugin: {command}. Exception: {ex.Message}", System.Drawing.Color.Crimson); + return false; + } + } + + public async void PlugDoFeature() + { + await ExecuteFeatureCommands(PlugDo); + } + + public async void PlugUndoFeature() + { + await ExecuteFeatureCommands(PlugUndo); + } + + private async Task ExecuteFeatureCommands(string[] commands) + { + foreach (var command in commands) + { + await ExecuteCommand(command); + } + } + + private async Task ExecuteCommand(string command) + { + try + { + var process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = IsPowerShellCommand(command) ? "powershell.exe" : "cmd.exe", + Arguments = IsPowerShellCommand(command) ? $"-Command \"{command}\"" : $"/c \"{command}\"", + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + } + }; + + // Event handler for handling output data + process.OutputDataReceived += (sender, e) => + { + if (!string.IsNullOrEmpty(e.Data)) + { + logger.Log($"Output: {e.Data}", System.Drawing.Color.Green); + } + }; + + // Event handler for handling error data + process.ErrorDataReceived += (sender, e) => + { + if (!string.IsNullOrEmpty(e.Data)) + { + logger.Log($"Error: {e.Data}", System.Drawing.Color.Crimson); + } + }; + + process.Start(); + + // Begin asynchronous reading of the output and error streams + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + + // Wait for the process to exit + await process.WaitForExitAsync(); + + // Log command execution + logger.Log($"Plugin executed command: {command}", System.Drawing.Color.Green); + } + catch (Exception ex) + { + logger.Log($"Error executing plugin: {command}. Exception: {ex.Message}", System.Drawing.Color.Crimson); + } + } + + // Determine if command should be run with Ps + private bool IsPowerShellCommand(string command) + { + return command.StartsWith("powershell.exe") || command.Contains("Get-") || command.Contains("Set-"); + } + + // Get plugin information + public string GetPluginInformation() + { + return $"{PlugInfo.Replace("\\n", Environment.NewLine)}"; + } + + private static void AddToPluginCategory(TreeNodeCollection pluginCategory, TreeNode node, string category) + { + if (pluginCategory == null) + throw new ArgumentNullException(nameof(pluginCategory)); + var existingCategory = pluginCategory.Cast().FirstOrDefault(n => n.Text == category); + + if (existingCategory == null) + { + existingCategory = new TreeNode(category) + { + // BackColor = System.Drawing.Color.LightBlue, + ForeColor = System.Drawing.Color.Black + }; + pluginCategory.Add(existingCategory); + } + + existingCategory.Nodes.Add(node); + } + + public static async Task LoadPlugins(string pluginDirectory, TreeNodeCollection pluginCategory, Logger logger) + { + if (Directory.Exists(pluginDirectory)) + { + var pluginFiles = Directory.GetFiles(pluginDirectory, "*.json"); + + foreach (var file in pluginFiles) + { + // Exclude JSON files of our DLL Plugins as they are loaded separately + if (Path.GetFileName(file).IndexOf("Plugin", StringComparison.OrdinalIgnoreCase) >= 0) + continue; + + try + { + var json = File.ReadAllText(file); + var plugin = JsonConvert.DeserializeObject(json); + + if (plugin != null) + { + plugin.logger = logger; // Set logger for the plugin + + // Execute all commands for the plugin to check its feature + bool isActive = plugin.PlugCheckFeature(); + + var pluginNode = new TreeNode(plugin.PlugID) + { + ToolTipText = plugin.PlugInfo, + Checked = isActive, + Tag = plugin // Store plugin object in Tag property + }; + + // Add to the appropriate category + AddToPluginCategory(pluginCategory, pluginNode, plugin.PlugCategory); + } + } + catch (Exception ex) + { + logger.Log($"Error loading plugin from file '{file}': {ex.Message}", System.Drawing.Color.Crimson); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/Bloatynosy/Locales/Strings.Designer.cs b/src/Bloatynosy/Locales/Strings.Designer.cs index 414e620..abaa86e 100644 --- a/src/Bloatynosy/Locales/Strings.Designer.cs +++ b/src/Bloatynosy/Locales/Strings.Designer.cs @@ -555,6 +555,15 @@ namespace BloatynosyNue.Locales { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Switch to Plugins Store ähnelt. + /// + internal static string ctl_btnStore { + get { + return ResourceManager.GetString("ctl_btnStore", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Donate ähnelt. /// @@ -641,11 +650,11 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Sort ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die More Infos ähnelt. /// - internal static string formDumputer_ctl_lblSort { + internal static string formDumputer_ctl_lblMoreInfo { get { - return ResourceManager.GetString("formDumputer_ctl_lblSort", resourceCulture); + return ResourceManager.GetString("formDumputer_ctl_lblMoreInfo", resourceCulture); } } @@ -659,7 +668,7 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Filter ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Search apps ähnelt. /// internal static string formDumputer_ctl_textBoxSearch { get { @@ -758,7 +767,7 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Enable All ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Activate All ähnelt. /// internal static string formExperience_ctl_btnApply { get { @@ -767,7 +776,7 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Disable All ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Deactivate All ähnelt. /// internal static string formExperience_ctl_btnRevert { get { @@ -784,15 +793,6 @@ namespace BloatynosyNue.Locales { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die Sort ähnelt. - /// - internal static string formExperience_ctl_lblSort { - get { - return ResourceManager.GetString("formExperience_ctl_lblSort", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die Click 'Enable All' to apply all changes, or 'Disable All' to revert to the default settings. You can also make individual adjustments as needed. ähnelt. /// @@ -803,7 +803,7 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Filter ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Search ähnelt. /// internal static string formExperience_ctl_textBoxSearch { get { @@ -885,7 +885,7 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die The plugin environment is not ready.\n\nWould you like to enable the store and download the required components? ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die The required plugin environment is not set up. Do you want to download the necessary components? ähnelt. /// internal static string formPlugins_status_notReady { get { @@ -957,11 +957,20 @@ namespace BloatynosyNue.Locales { } /// - /// Sucht eine lokalisierte Zeichenfolge, die About this app ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die About app ähnelt. /// - internal static string tt_btnAboutApp { + internal static string formSettings_ctl_lblSecAboutApp { get { - return ResourceManager.GetString("tt_btnAboutApp", resourceCulture); + return ResourceManager.GetString("formSettings_ctl_lblSecAboutApp", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Language ähnelt. + /// + internal static string formSettings_ctl_lblSecLanguage { + get { + return ResourceManager.GetString("formSettings_ctl_lblSecLanguage", resourceCulture); } } @@ -1000,5 +1009,14 @@ namespace BloatynosyNue.Locales { return ResourceManager.GetString("tt_btnPlugins", resourceCulture); } } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Settings ähnelt. + /// + internal static string tt_btnSettings { + get { + return ResourceManager.GetString("tt_btnSettings", resourceCulture); + } + } } } diff --git a/src/Bloatynosy/Locales/Strings.de.resx b/src/Bloatynosy/Locales/Strings.de.resx index 395cfb0..7defff9 100644 --- a/src/Bloatynosy/Locales/Strings.de.resx +++ b/src/Bloatynosy/Locales/Strings.de.resx @@ -141,14 +141,11 @@ App-Debloat - - Sortieren - Bewege Apps vom linken Korb in den rechten Mülleimer, um sie zu löschen. - Filtern + Apps durchsuchen Lade APPX-Pakete... @@ -162,14 +159,11 @@ Erlebnis personalisieren - - Sortieren - Klick auf 'Alle aktivieren', um alle Änderungen anzuwenden, oder 'Alle deaktivieren', um Standardwerte zu behalten. Einzelne Einstellungen kannst du separat anpassen. - Filtern + Durchsuchen Fehler bei der Aktualisierung des Funktionsstatus aufgrund fehlender Berechtigungen. @@ -201,8 +195,8 @@ Entdecke neue Möglichkeiten mit den Bloatynosy Nue Plugins - - Über diese App + + Einstellungen Entferne vorinstallierte Apps auf Windows 11 (24H2 und 23H2), um dein System aufzuräumen. @@ -429,4 +423,16 @@ App-Pakete geladen: + + Mehr Informationen + + + Sprache + + + Über diese App + + + Wechsle zum Plugin-Store + \ No newline at end of file diff --git a/src/Bloatynosy/Locales/Strings.it.resx b/src/Bloatynosy/Locales/Strings.it.resx index af7fc57..0ace02a 100644 --- a/src/Bloatynosy/Locales/Strings.it.resx +++ b/src/Bloatynosy/Locales/Strings.it.resx @@ -121,7 +121,7 @@ Indietro - Cassonetto™ + Pulizia™ Esperienza @@ -141,9 +141,6 @@ Dump applicazione - - Ordina - Sposta le app dal cestino di sinistra al cestino di destra per eliminarle @@ -162,9 +159,6 @@ Personalizza esperienza - - Ordina - Per procedere seleziona "Accetta e applica" o "Rifiuta" per mantenere le impostazioni predefinite. È inoltre possibile apportare modifiche individuali. @@ -202,7 +196,7 @@ Più possibilità con i plugin Bloatynosy Nue - + Info su questa app @@ -371,7 +365,7 @@ Bloatynosy Nue Questa funzione allineerà il pulsante Start a sinistra - Dettagli sull'app selezionata + Dettagli app selezionata Tentativo di rimozione diff --git a/src/Bloatynosy/Locales/Strings.ko.resx b/src/Bloatynosy/Locales/Strings.ko.resx new file mode 100644 index 0000000..7737c5d --- /dev/null +++ b/src/Bloatynosy/Locales/Strings.ko.resx @@ -0,0 +1,434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 뒤로 + + + Dumputer™ + + + 경험 + + + Windows 11 설정 + + + 다음을 수행하고자 합니다 + + + Windows 11 개인 정보 보호 및 개인화 수준을 높이고, 블로트웨어를 제거하여 깔끔하게 정리하고, 커뮤니티 플러그인으로 기능을 강화하세요. + + + 제거 + + + 응용 프로그램 덤프 + + + 앱을 왼쪽 바구니에서 오른쪽 쓰레기통으로 이동하여 삭제합니다 + + + 필터 + + + appx 패키지 로드 중... + + + 모두 활성화 + + + 모두 비활성화 + + + 사용자 지정 경험 + + + 모든 변경 사항을 적용하려면 '모두 활성화'를 클릭하고, 기본 설정으로 되돌리려면 '모두 비활성화'를 클릭합니다. 필요에 따라 개별적으로 조정할 수도 있습니다. + + + 필터 + + + 권한이 부족하여 기능 상태를 업데이트하지 못했습니다. + + + 비활성화 + + + 활성화 + + + 실행 + + + 스크립트 보기 + + + 선택 사항 검토 + + + 다음 + + + 스토어 방문 + + + 확장 + + + Bloatynosy Nue 의 더 많은 가능성 +플러그인 + + + 이 앱 정보 + + + Windows 11 (24H2 및 23H2)에서 사전 설치된 앱을 제거하여 시스템을 깔끔하게 정리하세요. + + + 향상된 개인 정보 보호, 제어 및 개인화를 위한 Windows 11 설정 사용자 지정 + + + 알림 + + + 플러그인 + + + 파일 탐색기 광고 비활성화 + + + 이 기능을 사용하면 파일 탐색기에서 광고가 비활성화됩니다. + + + 설정 완료 광고 비활성화 + + + 이 기능을 사용하면 '디바이스 설정을 완료하겠습니다' 및 기타 광고가 비활성화됩니다. + + + 잠금 화면 팁 및 광고 비활성화 + + + 이 기능을 사용하면 잠금 화면에서 팁과 광고를 비활성화할 수 있습니다. + + + 맞춤 광고 비활성화 + + + 이 기능을 사용하면 맞춤 광고가 비활성화됩니다. + + + 설정 광고 비활성화 + + + 이 기능은 설정에서 광고를 비활성화합니다. + + + 시작 메뉴 광고 비활성화 + + + 이 기능을 사용하면 시작 메뉴에서 광고가 비활성화됩니다. + + + 맞춤형 경험 비활성화 + + + 맞춤형 환경을 통해 Microsoft는 사용자로부터 정보를 얻어 개인화된 팁, 광고 및 추천을 제공할 수 있습니다. 많은 사람들이 이를 텔레메트리 또는 스파이라고 부릅니다. + + + 일반 팁 및 광고 비활성화 + + + 이 기능을 사용하면 일반 팁과 광고가 비활성화됩니다. + + + 환영 경험 광고 비활성화 + + + 이 기능을 사용하면 시작 환경에서 광고가 비활성화됩니다. + + + 작업 표시줄에 Copilot 표시 안 함 + + + 이 기능을 사용하면 작업 표시줄에서 Copilot이 비활성화됩니다. + + + 시스템 전체 스냅샷 허용 안 함 + + + 이 기능은 시스템 전체 스냅샷을 비활성화합니다. + + + Windows에서 화면 스냅샷 저장 허용 안 함 + + + 이 기능을 사용하면 화면의 스냅샷을 저장할 때 리콜 기능이 비활성화됩니다.” + + + 게임 DVR 비활성화 + + + 이 기능은 게임 DVR을 비활성화합니다. + + + 전원 스로틀링 비활성화 + + + 이 기능은 전원 스로틀링을 비활성화합니다. + + + 시각 효과 비활성화 + + + 이 기능은 Windows에서 시각 효과를 비활성화합니다. + + + 활동 기록 비활성화 + + + 위치 추적 비활성화 + + + 위치 추적 사용 안 함 (Windows가 사용자 위치에 액세스하지 못하도록 함) + + + 로그인 시 개인정보 설정 경험 비활성화 + + + 이 기능을 사용하면 로그인 시 개인정보 설정 경험이 비활성화됩니다. + + + 원격 측정 데이터 수집 끄기 + + + 이 기능은 원격 분석 데이터 수집을 끄고 데이터가 Microsoft로 전송되지 않도록 합니다. + + + Windows 11에서 전체 컨텍스트 메뉴 표시 + + + 이 기능을 사용하면 Windows 11에서 전체 상황에 맞는 메뉴를 사용할 수 있습니다. + + + 개인화된 잠금 화면 사용하지 않음 + + + 이 기능을 사용하면 개인화된 잠금 화면이 비활성화됩니다. + + + 작업 표시줄의 검색창 숨기기 + + + 이 기능은 작업 표시줄의 검색창을 숨깁니다. + + + 시작 메뉴에서 가장 많이 사용하는 앱 숨기기 + + + 이 기능은 시작 메뉴에서 가장 많이 사용하는 앱을 숨깁니다. + + + 작업 표시줄의 작업 보기 버튼 숨기기 + + + 이 기능은 작업 표시줄의 작업 보기 버튼을 숨깁니다. + + + 시작 메뉴에 더 많은 앱 고정 + + + 이 기능을 사용하면 시작 메뉴에 더 많은 앱을 고정할 수 있습니다 + + + 시작 버튼을 왼쪽으로 정렬 + + + 이 기능을 사용하면 시작 버튼이 왼쪽으로 정렬됩니다 + + + 선택한 앱에 대한 세부 정보 + + + 제거 시도 중 + + + 성공적으로 제거됨 + + + 오류 제거 + + + 휴지통에 아직 항목이 없습니다 + + + 앱 목록 새로 고침... + + + 새로 고침 + + + 추가 + + + 제거 + + + 활동 기록 사용 안 함 (Windows에서 활동을 추적 및 저장하지 못하도록 함) + + + 선택한 플러그인이 없습니다. 적용하거나 되돌릴 플러그인을 선택해 주세요. + + + 적용 대상 + + + 되돌리기 + + + 기부하기 + + + Bloatynosy Nue를 즐기고 있나요? 프로젝트를 후원하고 싶으시다면 기부를 통해 프로젝트를 계속 진행할 수 있습니다. 정말 감사합니다! +Bloatynosy Nue가 여러분의 하루를 더 편하게 만들어 주었다면, 이 마법이 계속 유지될 수 있도록 작은 기부금을 보내주세요! 작은 금액이지만 모두 도움이 됩니다! +Bloatynosy Nue가 하는 일이 마음에 드시나요? 작은 기부를 통해 더 나은 서비스를 만들 수 있도록 도와주세요! 미리 감사드립니다! 😄; +Bloatynosy Nue 덕분에 Windows 11을 즐기고 계신다면, 프로젝트가 계속 유지될 수 있도록 기부해 주세요. 정말 감사합니다! +Bloatynosy Nue의 결과가 마음에 드시나요? 기부를 통해 사랑을 표현해 보세요. 계속 개선하는 데 큰 도움이 됩니다! +Bloatynosy Nue가 도움이 되었다면 제가 이 멋진 도구를 계속 개발할 수 있도록 작은 기부금을 보내주세요. 작은 금액도 소중합니다! +Bloatynosy Nue가 여러분의 삶을 더 편하게 만들었다면, 제가 계속 개선할 수 있도록 기부해주시면 큰 도움이 될 것입니다. 후원해 주셔서 감사합니다! + + + + 기부하시겠습니까? + + + 설치됨 + + + 플러그인 환경이 준비되지 않았습니다.\n\n스토어를 활성화하고 필요한 구성 요소를 다운로드하시겠습니까? + + + 다운로드 완료! \n스토어를 사용할 준비가 되었습니다. + + + 앱 패키지가 로드됨: + + \ No newline at end of file diff --git a/src/Bloatynosy/Locales/Strings.resx b/src/Bloatynosy/Locales/Strings.resx index 514e781..cc0931f 100644 --- a/src/Bloatynosy/Locales/Strings.resx +++ b/src/Bloatynosy/Locales/Strings.resx @@ -141,35 +141,29 @@ Application Dump - - Sort - Move apps from the left basket to the right trash can to delete them - Filter + Search apps Loading appx packages... - Enable All + Activate All - Disable All + Deactivate All Customize Experience - - Sort - Click 'Enable All' to apply all changes, or 'Disable All' to revert to the default settings. You can also make individual adjustments as needed. - Filter + Search Failed to update feature status due to insufficient permissions. @@ -202,8 +196,8 @@ More Possibilities with Bloatynosy Nue Plugins - - About this app + + Settings Remove pre-installed apps on Windows 11 (24H2 and 23H2) to declutter your system @@ -429,7 +423,7 @@ If Bloatynosy Nue made life easier for you, a donation would go a long way in ma Installed - The plugin environment is not ready.\n\nWould you like to enable the store and download the required components? + The required plugin environment is not set up. Do you want to download the necessary components? Download complete! \nThe Store is ready to use. @@ -437,4 +431,16 @@ If Bloatynosy Nue made life easier for you, a donation would go a long way in ma App packages loaded: + + More Infos + + + Language + + + About app + + + Switch to Plugins Store + \ No newline at end of file diff --git a/src/Bloatynosy/PSPluginHandler.cs b/src/Bloatynosy/PSPluginHandler.cs new file mode 100644 index 0000000..a4bdc82 --- /dev/null +++ b/src/Bloatynosy/PSPluginHandler.cs @@ -0,0 +1,98 @@ +using BloatynosyNue; +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +public class PSPluginHandler +{ + public void LoadPowerShellPlugins(TreeView treeView) + { + var scriptDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); + + if (!Directory.Exists(scriptDirectory)) + { + MessageBox.Show("plugins directory does not exist."); + return; + } + + // Create a Dependencies category in the TreeView + TreeNode dependencyCategory = new TreeNode("Plugins"); + treeView.Nodes.Add(dependencyCategory); + + var scriptFiles = Directory.GetFiles(scriptDirectory, "*.ps1"); + + foreach (var file in scriptFiles) + { + var scriptName = Path.GetFileNameWithoutExtension(file); + + // Create a TreeNode for each ps script + var scriptNode = new TreeNode + { + ToolTipText = file, + Text = $"{scriptName} [PS]", + Tag = file // Store the file path as the Tag + }; + + // Add the script node to the Dependecy category + dependencyCategory.Nodes.Add(scriptNode); + } + } + + // Execute the selected PowerShell script + public async Task ExecutePlugin(string pluginPath, Logger logger) + { + try + { + using (var process = new Process()) + { + process.StartInfo.FileName = "powershell.exe"; + process.StartInfo.Arguments = $"-NoProfile -ExecutionPolicy Bypass -File \"{pluginPath}\""; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.RedirectStandardError = true; + process.StartInfo.UseShellExecute = false; + process.StartInfo.CreateNoWindow = true; + + var outputBuilder = new StringBuilder(); + var errorBuilder = new StringBuilder(); + + // Handle output from PowerShell script + process.OutputDataReceived += (sender, e) => + { + if (!string.IsNullOrEmpty(e.Data)) + { + outputBuilder.AppendLine(e.Data); + logger.Log($"PowerShell script output: {e.Data}", System.Drawing.Color.Black); + } + }; + + // Handle error from PowerShell script + process.ErrorDataReceived += (sender, e) => + { + if (!string.IsNullOrEmpty(e.Data)) + { + errorBuilder.AppendLine(e.Data); + logger.Log($"PowerShell script error: {e.Data}", System.Drawing.Color.Crimson); + } + }; + + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + + await Task.Run(() => + { + process.WaitForExit(); + }); + + logger.Log($"PowerShell script executed successfully: {pluginPath}", System.Drawing.Color.Green); + } + } + catch (Exception ex) + { + logger.Log($"Error executing PowerShell script: {pluginPath}. Exception: {ex.Message}", System.Drawing.Color.Crimson); + } + } +} \ No newline at end of file