Skip to content

Commit

Permalink
Small fix for starting when already admin or elevated (#25)
Browse files Browse the repository at this point in the history
* Updated discovery of VS instances to use the new WMI namespace Microsoft is using since 10/2023.
Now discovery tries the original WMI namespace, the new namespace and finally the Setup API.
Improvement on #18

* Added continuous GIT status updates
Added VS activity log access through a button

* Small fix for when starting as admin or elevated already to avoid restarting through taskscheduler

---------

Co-authored-by: Andreas Saurwein <[email protected]>
  • Loading branch information
Hefaistos68 and Andreas Saurwein authored Oct 18, 2023
1 parent 40be64d commit 895c05c
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 895c05c

Please sign in to comment.