File tree Expand file tree Collapse file tree 2 files changed +24
-14
lines changed
Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Original file line number Diff line number Diff line change 2626using Microsoft . Extensions . DependencyInjection ;
2727using Microsoft . Extensions . Hosting ;
2828using Microsoft . VisualStudio . Threading ;
29+ using Squirrel ;
2930
3031namespace Flow . Launcher
3132{
@@ -334,9 +335,27 @@ private static void RegisterTaskSchedulerUnhandledException()
334335
335336 #region Restart
336337
338+ /// <summary>
339+ /// Restart the application without changing the user privileges.
340+ /// </summary>
341+ public static void RestartApp ( bool forceAdmin = false )
342+ {
343+ if ( Win32Helper . IsAdministrator ( ) || forceAdmin )
344+ {
345+ RestartAppAsAdministrator ( ) ;
346+ }
347+ else
348+ {
349+ // Restart requires Squirrel's Update.exe to be present in the parent folder,
350+ // it is only published from the project's release pipeline. When debugging without it,
351+ // the project may not restart or just terminates. This is expected.
352+ UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
353+ }
354+ }
355+
337356 // Since Squirrel does not provide a way to restart the app as administrator,
338357 // we need to do it manually by starting the update.exe with the runas verb
339- public static void RestartAppAsAdministrator ( )
358+ private static void RestartAppAsAdministrator ( )
340359 {
341360 var startInfo = new ProcessStartInfo
342361 {
Original file line number Diff line number Diff line change 3131using Flow . Launcher . Plugin . SharedCommands ;
3232using Flow . Launcher . ViewModel ;
3333using JetBrains . Annotations ;
34- using Squirrel ;
3534using Stopwatch = Flow . Launcher . Infrastructure . Stopwatch ;
3635
3736namespace Flow . Launcher
@@ -85,18 +84,10 @@ public async void RestartApp()
8584 // Wait for all image caches to be saved before restarting
8685 await ImageLoader . WaitSaveAsync ( ) ;
8786
88- // If app is run as administrator already, we continue to restart app as administrator
89- if ( Win32Helper . IsAdministrator ( ) )
90- {
91- App . RestartAppAsAdministrator ( ) ;
92- }
93- else
94- {
95- // Restart requires Squirrel's Update.exe to be present in the parent folder,
96- // it is only published from the project's release pipeline. When debugging without it,
97- // the project may not restart or just terminates. This is expected.
98- UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
99- }
87+ // Restart requires Squirrel's Update.exe to be present in the parent folder,
88+ // it is only published from the project's release pipeline. When debugging without it,
89+ // the project may not restart or just terminates. This is expected.
90+ App . RestartApp ( ) ;
10091 }
10192
10293 public void ShowMainWindow ( ) => _mainVM . Show ( ) ;
You can’t perform that action at this time.
0 commit comments