Add run as administrator option

This commit is contained in:
Ray Berezowski
2026-08-26 22:10:55 -04:00
parent 6d9bbbab02
commit 1601da8155
9 changed files with 84 additions and 4 deletions

View File

@@ -183,6 +183,7 @@ public sealed class LauncherController : IDisposable
IconPath = item.IconPath,
IsFavorite = false,
IsDisabled = false,
RunAsAdmin = item.RunAsAdmin,
DisplayMode = item.DisplayMode,
Children = []
};
@@ -286,6 +287,11 @@ public sealed class LauncherController : IDisposable
WorkingDirectory = Directory.Exists(target) ? target : ConfigService.AppFolder
};
if (item.RunAsAdmin && CanRunAsAdmin(item.Type))
{
startInfo.Verb = "runas";
}
Process.Start(startInfo);
return true;
}
@@ -295,4 +301,9 @@ public sealed class LauncherController : IDisposable
return false;
}
}
public static bool CanRunAsAdmin(LauncherItemType itemType)
{
return itemType is LauncherItemType.App or LauncherItemType.File;
}
}