mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Added ExtensionManager safety checks
This commit is contained in:
parent
86d91a3e4b
commit
e13a57009a
@ -33,25 +33,26 @@ namespace Wabbajack.Common
|
||||
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
|
||||
var tempKey = progIDKey?.OpenSubKey("shell\\open\\command");
|
||||
if (progIDKey == null || tempKey == null) return true;
|
||||
return tempKey.GetValue("").ToString().Equals($"\"{appPath}\" -i \"%1\"");
|
||||
var value = tempKey.GetValue("");
|
||||
return value == null || value.ToString().Equals($"\"{appPath}\" -i \"%1\"");
|
||||
}
|
||||
|
||||
public static bool IsAssociated()
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
|
||||
var extKey = Registry.CurrentUser.OpenSubKey(ExtPath);
|
||||
return (progIDKey != null && extKey != null);
|
||||
return progIDKey != null && extKey != null;
|
||||
}
|
||||
|
||||
public static void Associate(string appPath)
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.CreateSubKey(ProgIDPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
foreach (KeyValuePair<string, string> entry in ProgIDList)
|
||||
foreach (var entry in ProgIDList)
|
||||
{
|
||||
if (entry.Key.Contains("\\"))
|
||||
{
|
||||
var tempKey = progIDKey.CreateSubKey(entry.Key);
|
||||
tempKey.SetValue("", entry.Value.Replace("{appPath}", appPath));
|
||||
var tempKey = progIDKey?.CreateSubKey(entry.Key);
|
||||
tempKey?.SetValue("", entry.Value.Replace("{appPath}", appPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -60,7 +61,7 @@ namespace Wabbajack.Common
|
||||
}
|
||||
|
||||
var extKey = Registry.CurrentUser.CreateSubKey(ExtPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
foreach (KeyValuePair<string, string> entry in ExtList)
|
||||
foreach (var entry in ExtList)
|
||||
{
|
||||
extKey?.SetValue(entry.Key, entry.Value);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Windows;
|
||||
using MahApps.Metro.Controls;
|
||||
using Wabbajack.Common;
|
||||
using Application = System.Windows.Application;
|
||||
using Utils = Wabbajack.Common.Utils;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -25,10 +26,18 @@ namespace Wabbajack
|
||||
};
|
||||
|
||||
var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
try
|
||||
{
|
||||
if (!ExtensionManager.IsAssociated() || ExtensionManager.NeedsUpdating(appPath))
|
||||
{
|
||||
ExtensionManager.Associate(appPath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.Log($"ExtensionManager had an exception:\n{e}");
|
||||
}
|
||||
|
||||
|
||||
Wabbajack.Common.Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user