소스 검색

Added restart command arguments

deadmoon 3 년 전
부모
커밋
e199f39342
2개의 변경된 파일23개의 추가작업 그리고 2개의 파일을 삭제
  1. 22 1
      Optimizer/Program.cs
  2. 1 1
      Optimizer/Utilities.cs

+ 22 - 1
Optimizer/Program.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Reflection;
@@ -154,12 +155,32 @@ namespace Optimizer
                                 // displays build info
                                 if (arg == "/version")
                                 {
-                                    if (!Program.EXPERIMENTAL_BUILD) MessageBox.Show($"Optimizer: {Program.GetCurrentVersionTostring()}\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                                    if (!EXPERIMENTAL_BUILD) MessageBox.Show($"Optimizer: {GetCurrentVersionTostring()}\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                     else MessageBox.Show("Optimizer: EXPERIMENTAL BUILD. PLEASE DELETE AFTER TESTING.\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
 
                                     Environment.Exit(0);
                                 }
 
+                                // instruct to restart in safe-mode
+                                if (arg == "/restart=safemode")
+                                {
+                                    Utilities.RunCommand("bcdedit /set {current} safeboot Minimal");
+                                    Thread.Sleep(500);
+                                    Utilities.Reboot();
+
+                                    Environment.Exit(0);
+                                }
+
+                                // instruct to restart normally
+                                if (arg == "/restart=normal")
+                                {
+                                    Utilities.RunCommand("bcdedit /deletevalue {current} safeboot");
+                                    Thread.Sleep(500);
+                                    Utilities.Reboot();
+
+                                    Environment.Exit(0);
+                                }
+
                                 // other options 
                                 if (arg.StartsWith("/disable="))
                                 {

+ 1 - 1
Optimizer/Utilities.cs

@@ -27,7 +27,7 @@ namespace Optimizer
         internal static readonly string LocalMachineRunOnceWow = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
         internal static readonly string CurrentUserRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
         internal static readonly string CurrentUserRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
-
+        
         internal static readonly string LocalMachineStartupFolder = CleanHelper.ProgramData + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
         internal static readonly string CurrentUserStartupFolder = CleanHelper.ProfileAppDataRoaming + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";