Add run as administrator option
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user