Skip to content

Commit

Permalink
Small fix for when starting as admin or elevated already to avoid res…
Browse files Browse the repository at this point in the history
…tarting through taskscheduler
  • Loading branch information
Andreas Saurwein committed Oct 18, 2023
1 parent a7e3507 commit 83bc15e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion VSLauncherX/Helpers/AutoRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static string GetUserName(WindowsIdentity user)
/// <summary>
/// Runs the.
/// </summary>
internal static void Run()
internal static bool Run()
{
// Get the service on the local machine
using (TaskService ts = new TaskService())
Expand All @@ -129,8 +129,11 @@ internal static void Run()
if (folder.AllTasks.Any(t => t.Name == taskName))
{
folder.Tasks[taskName].Run();
return true;
}
}

return false;
}

/// <summary>
Expand Down
11 changes: 9 additions & 2 deletions VSLauncherX/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ static void Main()
UpdateTaskScheduler();
}

if (!Settings.Default.AlwaysAdmin)
bool bAdmin = AdminInfo.IsCurrentUserAdmin();
bool bElevated = AdminInfo.IsElevated();

if (!Settings.Default.AlwaysAdmin || bAdmin || bElevated)
{
Application.Run(new MainDialog());
}
else
{
// we are started normally
AutoRun.Run();
if(!AutoRun.Run())
{
Application.Run(new MainDialog());
}

}
}
}
Expand Down

0 comments on commit 83bc15e

Please sign in to comment.