diff --git a/Consts/MainConst.cs b/Consts/MainConst.cs index fe6d0c8..dedcd03 100644 --- a/Consts/MainConst.cs +++ b/Consts/MainConst.cs @@ -21,8 +21,6 @@ internal partial class MainConst : MainMultilangConst internal static string EdgeBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe"; internal static string ChromeBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe"; internal static string BraveBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\brave.exe"; - internal static string UncealedBrowserPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Uncealed-Browser.lnk"); - internal static string UncealedBrowserDescription => "Created By Sheas Cealer"; internal static string HostsConfPath => Path.Combine(Registry.LocalMachine.OpenSubKey(@"\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath")?.GetValue("DataBasePath", null)?.ToString() ?? @"C:\Windows\System32\drivers\etc", "hosts"); internal static string HostsConfStartMarker => "# Cealing Nginx Start\n"; diff --git a/Utils/CommandProc.cs b/Utils/BrowserProc.cs similarity index 63% rename from Utils/CommandProc.cs rename to Utils/BrowserProc.cs index eba3bf8..a1c8a1a 100644 --- a/Utils/CommandProc.cs +++ b/Utils/BrowserProc.cs @@ -4,11 +4,11 @@ using SheasCore; namespace Sheas_Cealer.Utils; -internal class CommandProc : Proc +internal class BrowserProc : Proc { private static bool ShutDownAppOnProcessExit; - internal CommandProc(bool shutDownAppOnProcessExit) : base("Cmd.exe") => ShutDownAppOnProcessExit = shutDownAppOnProcessExit; + internal BrowserProc(string browserPath, bool shutDownAppOnProcessExit) : base(browserPath) => ShutDownAppOnProcessExit = shutDownAppOnProcessExit; public override void Process_Exited(object sender, EventArgs e) { diff --git a/Wins/MainWin.xaml.cs b/Wins/MainWin.xaml.cs index e52a555..7cd3eb4 100644 --- a/Wins/MainWin.xaml.cs +++ b/Wins/MainWin.xaml.cs @@ -14,7 +14,6 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; -using IWshRuntimeLibrary; using MaterialDesignThemes.Wpf; using Microsoft.Win32; using NginxConfigParser; @@ -151,12 +150,7 @@ public partial class MainWin : Window if (MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) return; - IWshShortcut uncealedBrowserShortcut = (IWshShortcut)new WshShell().CreateShortcut(MainConst.UncealedBrowserPath); - uncealedBrowserShortcut.TargetPath = MainPres!.BrowserPath; - uncealedBrowserShortcut.Description = MainConst.UncealedBrowserDescription; - uncealedBrowserShortcut.Save(); - - foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath))) + foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres!.BrowserPath))) { browserProcess.Kill(); await browserProcess.WaitForExitAsync(); @@ -164,7 +158,7 @@ public partial class MainWin : Window await Task.Run(() => { - new CommandProc(sender == null).ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, ($"{CealArgs} {MainPres!.ExtraArgs}").Trim()); + new BrowserProc(MainPres.BrowserPath, sender == null).ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, ($"{CealArgs} {MainPres.ExtraArgs}").Trim()); }); } private void NginxButton_Click(object sender, RoutedEventArgs e) @@ -543,7 +537,7 @@ public partial class MainWin : Window hostResolverRules += $"MAP {cealHostSniWithoutNull} {cealHostIp},"; } - CealArgs = @$"/c @start .\""{Path.GetFileName(MainConst.UncealedBrowserPath)}"" --host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors"; + CealArgs = @$"--host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors"; NginxConfWatcher_Changed(null!, null!); }