File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,8 @@ private static bool CheckLogonTask(bool alwaysRunAsAdministrator)
6464 if ( task . Definition . Actions . FirstOrDefault ( ) is Microsoft . Win32 . TaskScheduler . Action taskAction )
6565 {
6666 var action = taskAction . ToString ( ) . Trim ( ) ;
67- if ( ! action . Equals ( Constant . ExecutablePath , StringComparison . OrdinalIgnoreCase ) )
67+ if ( ! action . Equals ( Constant . ExecutablePath , StringComparison . OrdinalIgnoreCase ) || // Path issue
68+ ! CheckRunLevel ( task . Definition . Principal , alwaysRunAsAdministrator ) ) // Run level issue
6869 {
6970 UnscheduleLogonTask ( ) ;
7071 ScheduleLogonTask ( alwaysRunAsAdministrator ) ;
@@ -83,6 +84,11 @@ private static bool CheckLogonTask(bool alwaysRunAsAdministrator)
8384 return false ;
8485 }
8586
87+ private static bool CheckRunLevel ( TaskPrincipal tp , bool alwaysRunAsAdministrator )
88+ {
89+ return alwaysRunAsAdministrator ? tp . RunLevel == TaskRunLevel . Highest : tp . RunLevel != TaskRunLevel . Highest ;
90+ }
91+
8692 private static bool CheckRegistry ( )
8793 {
8894 try
You can’t perform that action at this time.
0 commit comments