mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 01:51:29 -07:00
Add exception handler for registry key writing
This commit is contained in:
parent
fe04b468b0
commit
d8f1e27585
@ -252,7 +252,7 @@ namespace Bloxstrap
|
|||||||
clientVersion = await RobloxDeployment.GetInfo(channel, AppData.BinaryType);
|
clientVersion = await RobloxDeployment.GetInfo(channel, AppData.BinaryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
key.SetValue("www.roblox.com", channel);
|
key.SetValueSafe("www.roblox.com", channel);
|
||||||
|
|
||||||
_latestVersionGuid = clientVersion.VersionGuid;
|
_latestVersionGuid = clientVersion.VersionGuid;
|
||||||
|
|
||||||
@ -724,7 +724,7 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey))
|
using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey))
|
||||||
{
|
{
|
||||||
uninstallKey.SetValue("EstimatedSize", totalSize);
|
uninstallKey.SetValueSafe("EstimatedSize", totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Registered as {totalSize} KB");
|
App.Logger.WriteLine(LOG_IDENT, $"Registered as {totalSize} KB");
|
||||||
|
21
Bloxstrap/Extensions/RegistryKeyEx.cs
Normal file
21
Bloxstrap/Extensions/RegistryKeyEx.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
|
namespace Bloxstrap.Extensions
|
||||||
|
{
|
||||||
|
public static class RegistryKeyEx
|
||||||
|
{
|
||||||
|
public static void SetValueSafe(this RegistryKey registryKey, string? name, object value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine("RegistryKeyEx::SetValueSafe", $"Writing '{value}' to {registryKey}\\{name}");
|
||||||
|
registryKey.SetValue(name, value);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Frontend.ShowMessageBox(Strings.Dialog_RegistryWriteError, System.Windows.MessageBoxImage.Error);
|
||||||
|
App.Terminate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -53,23 +53,23 @@ namespace Bloxstrap
|
|||||||
// TODO: registry access checks, i'll need to look back on issues to see what the error looks like
|
// TODO: registry access checks, i'll need to look back on issues to see what the error looks like
|
||||||
using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey))
|
using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey))
|
||||||
{
|
{
|
||||||
uninstallKey.SetValue("DisplayIcon", $"{Paths.Application},0");
|
uninstallKey.SetValueSafe("DisplayIcon", $"{Paths.Application},0");
|
||||||
uninstallKey.SetValue("DisplayName", App.ProjectName);
|
uninstallKey.SetValueSafe("DisplayName", App.ProjectName);
|
||||||
|
|
||||||
uninstallKey.SetValue("DisplayVersion", App.Version);
|
uninstallKey.SetValueSafe("DisplayVersion", App.Version);
|
||||||
|
|
||||||
if (uninstallKey.GetValue("InstallDate") is null)
|
if (uninstallKey.GetValue("InstallDate") is null)
|
||||||
uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
|
uninstallKey.SetValueSafe("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
|
||||||
|
|
||||||
uninstallKey.SetValue("InstallLocation", Paths.Base);
|
uninstallKey.SetValueSafe("InstallLocation", Paths.Base);
|
||||||
uninstallKey.SetValue("NoRepair", 1);
|
uninstallKey.SetValueSafe("NoRepair", 1);
|
||||||
uninstallKey.SetValue("Publisher", App.ProjectOwner);
|
uninstallKey.SetValueSafe("Publisher", App.ProjectOwner);
|
||||||
uninstallKey.SetValue("ModifyPath", $"\"{Paths.Application}\" -settings");
|
uninstallKey.SetValueSafe("ModifyPath", $"\"{Paths.Application}\" -settings");
|
||||||
uninstallKey.SetValue("QuietUninstallString", $"\"{Paths.Application}\" -uninstall -quiet");
|
uninstallKey.SetValueSafe("QuietUninstallString", $"\"{Paths.Application}\" -uninstall -quiet");
|
||||||
uninstallKey.SetValue("UninstallString", $"\"{Paths.Application}\" -uninstall");
|
uninstallKey.SetValueSafe("UninstallString", $"\"{Paths.Application}\" -uninstall");
|
||||||
uninstallKey.SetValue("HelpLink", App.ProjectHelpLink);
|
uninstallKey.SetValueSafe("HelpLink", App.ProjectHelpLink);
|
||||||
uninstallKey.SetValue("URLInfoAbout", App.ProjectSupportLink);
|
uninstallKey.SetValueSafe("URLInfoAbout", App.ProjectSupportLink);
|
||||||
uninstallKey.SetValue("URLUpdateInfo", App.ProjectDownloadLink);
|
uninstallKey.SetValueSafe("URLUpdateInfo", App.ProjectDownloadLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only register player, for the scenario where the user installs bloxstrap, closes it,
|
// only register player, for the scenario where the user installs bloxstrap, closes it,
|
||||||
@ -426,12 +426,12 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey))
|
using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey))
|
||||||
{
|
{
|
||||||
uninstallKey.SetValue("DisplayVersion", App.Version);
|
uninstallKey.SetValueSafe("DisplayVersion", App.Version);
|
||||||
|
|
||||||
uninstallKey.SetValue("Publisher", App.ProjectOwner);
|
uninstallKey.SetValueSafe("Publisher", App.ProjectOwner);
|
||||||
uninstallKey.SetValue("HelpLink", App.ProjectHelpLink);
|
uninstallKey.SetValueSafe("HelpLink", App.ProjectHelpLink);
|
||||||
uninstallKey.SetValue("URLInfoAbout", App.ProjectSupportLink);
|
uninstallKey.SetValueSafe("URLInfoAbout", App.ProjectSupportLink);
|
||||||
uninstallKey.SetValue("URLUpdateInfo", App.ProjectDownloadLink);
|
uninstallKey.SetValueSafe("URLUpdateInfo", App.ProjectDownloadLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update migrations
|
// update migrations
|
||||||
|
9
Bloxstrap/Resources/Strings.Designer.cs
generated
9
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -1021,6 +1021,15 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Bloxstrap is unable to write to the Windows Registry. An antivirus is likely interfering and causing issues. Please check to make sure there isn't anything that would restrict Bloxstrap's operation..
|
||||||
|
/// </summary>
|
||||||
|
public static string Dialog_RegistryWriteError {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Dialog.RegistryWriteError", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Early 2015.
|
/// Looks up a localized string similar to Early 2015.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1204,4 +1204,7 @@ Please manually delete Bloxstrap.exe from the install location or try restarting
|
|||||||
<data name="Menu.Shortcuts.ExtractIcons.Description" xml:space="preserve">
|
<data name="Menu.Shortcuts.ExtractIcons.Description" xml:space="preserve">
|
||||||
<value>To use for your shortcuts, right-click it, open properties, change icon, browse, and pick from the Icons folder.</value>
|
<value>To use for your shortcuts, right-click it, open properties, change icon, browse, and pick from the Icons folder.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Dialog.RegistryWriteError" xml:space="preserve">
|
||||||
|
<value>Bloxstrap is unable to write to the Windows Registry. An antivirus is likely interfering and causing issues. Please check to make sure there isn't anything that would restrict Bloxstrap's operation.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -16,14 +16,14 @@ namespace Bloxstrap.Utility
|
|||||||
|
|
||||||
if (uriKey.GetValue("") is null)
|
if (uriKey.GetValue("") is null)
|
||||||
{
|
{
|
||||||
uriKey.SetValue("", $"URL: {name} Protocol");
|
uriKey.SetValueSafe("", $"URL: {name} Protocol");
|
||||||
uriKey.SetValue("URL Protocol", "");
|
uriKey.SetValueSafe("URL Protocol", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uriCommandKey.GetValue("") as string != handlerArgs)
|
if (uriCommandKey.GetValue("") as string != handlerArgs)
|
||||||
{
|
{
|
||||||
uriIconKey.SetValue("", handler);
|
uriIconKey.SetValueSafe("", handler);
|
||||||
uriCommandKey.SetValue("", handlerArgs);
|
uriCommandKey.SetValueSafe("", handlerArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,16 +85,16 @@ namespace Bloxstrap.Utility
|
|||||||
using RegistryKey uriCommandKey = uriOpenKey.CreateSubKey(@"command");
|
using RegistryKey uriCommandKey = uriOpenKey.CreateSubKey(@"command");
|
||||||
|
|
||||||
if (uriKey.GetValue("") as string != keyValue)
|
if (uriKey.GetValue("") as string != keyValue)
|
||||||
uriKey.SetValue("", keyValue);
|
uriKey.SetValueSafe("", keyValue);
|
||||||
|
|
||||||
if (uriCommandKey.GetValue("") as string != handlerArgs)
|
if (uriCommandKey.GetValue("") as string != handlerArgs)
|
||||||
uriCommandKey.SetValue("", handlerArgs);
|
uriCommandKey.SetValueSafe("", handlerArgs);
|
||||||
|
|
||||||
if (uriOpenKey.GetValue("") as string != "Open")
|
if (uriOpenKey.GetValue("") as string != "Open")
|
||||||
uriOpenKey.SetValue("", "Open");
|
uriOpenKey.SetValueSafe("", "Open");
|
||||||
|
|
||||||
if (uriIconKey.GetValue("") as string != iconValue)
|
if (uriIconKey.GetValue("") as string != iconValue)
|
||||||
uriIconKey.SetValue("", iconValue);
|
uriIconKey.SetValueSafe("", iconValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterStudioFileType(string key)
|
public static void RegisterStudioFileType(string key)
|
||||||
@ -103,7 +103,7 @@ namespace Bloxstrap.Utility
|
|||||||
uriKey.CreateSubKey(RobloxPlaceKey + @"\ShellNew");
|
uriKey.CreateSubKey(RobloxPlaceKey + @"\ShellNew");
|
||||||
|
|
||||||
if (uriKey.GetValue("") as string != RobloxPlaceKey)
|
if (uriKey.GetValue("") as string != RobloxPlaceKey)
|
||||||
uriKey.SetValue("", RobloxPlaceKey);
|
uriKey.SetValueSafe("", RobloxPlaceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Unregister(string key)
|
public static void Unregister(string key)
|
||||||
|
Loading…
Reference in New Issue
Block a user