mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add support for running RobloxPlayerBeta as Admin
for some reason, i'm unable to delete the appcompatflags entry programatically in the uninstall process? weird
This commit is contained in:
parent
643a1f0db2
commit
aab9e153d1
@ -11,6 +11,8 @@
|
|||||||
#warning "Automatic updater debugging is enabled"
|
#warning "Automatic updater debugging is enabled"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Shell;
|
using System.Windows.Shell;
|
||||||
@ -337,7 +339,12 @@ namespace Bloxstrap
|
|||||||
WorkingDirectory = AppData.Directory
|
WorkingDirectory = AppData.Directory
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_launchMode == LaunchMode.StudioAuth)
|
if (_launchMode == LaunchMode.Player && ShouldRunAsAdmin())
|
||||||
|
{
|
||||||
|
startInfo.Verb = "runas";
|
||||||
|
startInfo.UseShellExecute = true;
|
||||||
|
}
|
||||||
|
else if (_launchMode == LaunchMode.StudioAuth)
|
||||||
{
|
{
|
||||||
Process.Start(startInfo);
|
Process.Start(startInfo);
|
||||||
return;
|
return;
|
||||||
@ -372,6 +379,11 @@ namespace Bloxstrap
|
|||||||
using var process = Process.Start(startInfo)!;
|
using var process = Process.Start(startInfo)!;
|
||||||
_appPid = process.Id;
|
_appPid = process.Id;
|
||||||
}
|
}
|
||||||
|
catch (Win32Exception ex) when (ex.NativeErrorCode == 1223)
|
||||||
|
{
|
||||||
|
// 1223 = ERROR_CANCELLED, gets thrown if a UAC prompt is cancelled
|
||||||
|
return;
|
||||||
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// attempt a reinstall on next launch
|
// attempt a reinstall on next launch
|
||||||
@ -456,6 +468,24 @@ namespace Bloxstrap
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool ShouldRunAsAdmin()
|
||||||
|
{
|
||||||
|
foreach (var root in WindowsRegistry.Roots)
|
||||||
|
{
|
||||||
|
using var key = root.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
|
||||||
|
|
||||||
|
if (key is null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string? flags = (string?)key.GetValue(AppData.ExecutablePath);
|
||||||
|
|
||||||
|
if (flags is not null && flags.Contains("RUNASADMIN", StringComparison.OrdinalIgnoreCase))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
const string LOG_IDENT = "Bootstrapper::Cancel";
|
const string LOG_IDENT = "Bootstrapper::Cancel";
|
||||||
|
@ -6,6 +6,8 @@ namespace Bloxstrap.Utility
|
|||||||
{
|
{
|
||||||
private const string RobloxPlaceKey = "Roblox.Place";
|
private const string RobloxPlaceKey = "Roblox.Place";
|
||||||
|
|
||||||
|
public static readonly List<RegistryKey> Roots = new() { Registry.CurrentUser, Registry.LocalMachine };
|
||||||
|
|
||||||
public static void RegisterProtocol(string key, string name, string handler, string handlerParam = "%1")
|
public static void RegisterProtocol(string key, string name, string handler, string handlerParam = "%1")
|
||||||
{
|
{
|
||||||
string handlerArgs = $"\"{handler}\" {handlerParam}";
|
string handlerArgs = $"\"{handler}\" {handlerParam}";
|
||||||
|
Loading…
Reference in New Issue
Block a user