File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,7 @@ public int Run()
6464 if ( ! IsAdministrator ( ) )
6565 {
6666 // Restart the application with elevated privileges
67- ElevateApplication ( ) ;
68- return 1 ;
67+ return ElevateApplication ( ) ;
6968 }
7069
7170 //
@@ -111,7 +110,7 @@ private static bool IsAdministrator()
111110 return principal . IsInRole ( WindowsBuiltInRole . Administrator ) ;
112111 }
113112
114- private static void ElevateApplication ( )
113+ private static int ElevateApplication ( )
115114 {
116115 var currentProcessModule = Process . GetCurrentProcess ( ) . MainModule ;
117116 if ( currentProcessModule == null ) throw new Exception ( "Unable to get the current process module" ) ;
@@ -130,10 +129,13 @@ private static void ElevateApplication()
130129 try
131130 {
132131 process . Start ( ) ;
132+ process . WaitForExit ( ) ;
133+ return process . ExitCode ;
133134 }
134135 catch ( Exception ex )
135136 {
136137 Console . Error . WriteLine ( "Could not restart as Administrator: " + ex . Message ) ;
138+ return 1 ;
137139 }
138140 }
139141
Original file line number Diff line number Diff line change 44 <OutputType >Exe</OutputType >
55 <TargetFramework >net8.0-windows</TargetFramework >
66 <AppendTargetFrameworkToOutputPath >false</AppendTargetFrameworkToOutputPath >
7- <Version >1.4.1 </Version >
7+ <Version >1.4.2 </Version >
88 <!-- Single file app – https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file -->
99 <PublishSingleFile >true</PublishSingleFile >
1010 <RuntimeIdentifier >win-x64</RuntimeIdentifier >
You can’t perform that action at this time.
0 commit comments