Skip to content

Commit

Permalink
Fixed SafelyRestartExplorerProcess bug 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
Inestic committed Apr 27, 2022
1 parent 6a58337 commit d739bb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions SophiApp/SophiApp/Helpers/OsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ internal static void SafelyRestartExplorerProcess()
// Terminate the File Explorer process
RegHelper.SetValue(RegistryHive.LocalMachine, WINLOGON_PATH, AUTORESTART_SHELL, DISABLED_VALUE, RegistryValueKind.DWord);
ProcessHelper.Stop(EXPLORER);
_ = Task.Delay(TIMEOUT_3_SECONDS);
Task.Delay(TIMEOUT_3_SECONDS).Wait();
RegHelper.SetValue(RegistryHive.LocalMachine, WINLOGON_PATH, AUTORESTART_SHELL, ENABLED_VALUE, RegistryValueKind.DWord);
// Start the File Explorer process
ProcessHelper.StartWait(EXPLORER);
Thread.Sleep(TIMEOUT_3_SECONDS);
_ = ProcessHelper.Start(EXPLORER);
Task.Delay(TIMEOUT_3_SECONDS).Wait();
// Restoring closed folders
ProcessHelper.StartWait(EXPLORER, openedFolders, ProcessWindowStyle.Minimized);
_ = Task.Delay(TIMEOUT_3_SECONDS);
Task.Delay(TIMEOUT_3_SECONDS).Wait();
}

internal static void SetRecommendedTroubleshooting(byte autoOrDefault)
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Helpers/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static IEnumerable<WindowsIdentity> GetProcessIdentity(string process)

internal static bool ProcessExist(string processName) => Process.GetProcessesByName(processName).Count() > 0;

internal static Process Start(string processName, string args, ProcessWindowStyle windowStyle)
internal static Process Start(string processName, string args = null, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)
{
return Process.Start(new ProcessStartInfo()
{
Expand Down

0 comments on commit d739bb1

Please sign in to comment.