public static void Save(GameSave save) { //ClearSave(); var values = save.GetValues(); using (var re = new RegistryEditor("Software\\Delve Interactive\\CHANGE")) { foreach (var kvp in values) { var key = RegistryKeyMapper.GetKey(kvp.Key); re.SetValue(key, kvp.Value); } save.Unknown.ForEach(item => re.SetValue(item.Key, item.Value)); foreach (var kvp in save.Perks) { var key = RegistryKeyMapper.GetKey("perk_" + kvp.Key.ToString()); re.SetValue(key, kvp.Value ? 1 : 0); } foreach (var item in save.Inventory.Items) { var key = RegistryKeyMapper.GetKey("item_" + item.name); re.SetValue(key, item.amount); } } }
void RemoveAppExecute(object param) { if (param is List <object> values) { var machine = values.FirstOrDefault() as string; var appKey = values.LastOrDefault() as string; using (registryEditor = new RegistryEditor(machine, RegistryLookupSourceEnum.Machine)) { try { registryEditor.RemoveStartupAppByKey(appKey); var element = ComputersData.FirstOrDefault(x => x.ComputerName == machine) .Data .FirstOrDefault(x => x.Key == appKey); ComputersData.FirstOrDefault(x => x.ComputerName == machine).Data.Remove(element); Notify(nameof(ComputersData)); System.Windows.MessageBox.Show("Removed"); } catch (Exception e) { System.Windows.MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
public static void HandleCreateRegistryKey(DoCreateRegistryKey packet, Networking.Client client) { GetCreateRegistryKeyResponse responsePacket = new GetCreateRegistryKeyResponse(); string errorMsg; string newKeyName = ""; try { responsePacket.IsError = !(RegistryEditor.CreateRegistryKey(packet.ParentPath, out newKeyName, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.Match = new RegSeekerMatch { Key = newKeyName, Data = RegistryKeyHelper.GetDefaultValues(), HasSubKeys = false }; responsePacket.ParentPath = packet.ParentPath; client.Send(responsePacket); }
private void RegisterDependencies() { DependencyManager.LogWriter = _logWriter; var appSettings = GetAppSettings(); // Providers var credentialsProvider = new CredentialsProvider(); var fileIoProvider = new FileIoProvider(); var registryProvider = new RegistryProvider(); var userProvider = new UserProvider(); var windowsApiProvider = new WindowsApiProvider(); var windowsServiceProviderFactory = new WindowsServiceProviderFactory(); var powerShellProvider = new PowerShellProvider(); var windowsTaskProvider = new WindowsTaskProvider(); // Services var fileManager = new FileManager(fileIoProvider, windowsApiProvider, credentialsProvider); DependencyManager.FileManager = fileManager; DependencyManager.HostsFileEditor = new HostsFileEditor(fileIoProvider, appSettings.WindowsUpdateUrls); var registryEditor = new RegistryEditor(windowsApiProvider, registryProvider, userProvider); DependencyManager.RegistryEditor = registryEditor; DependencyManager.WindowsServiceManager = new WindowsServiceManager(windowsServiceProviderFactory, registryEditor, fileManager, appSettings.WindowsServices); DependencyManager.WindowsPackageManager = new WindowsPackageManager(powerShellProvider, appSettings.Declutter); DependencyManager.WindowsTaskManager = new WindowsTaskManager(windowsTaskProvider, appSettings.WindowsTasks); }
private void Execute(ISender client, DoCreateRegistryKey message) { GetCreateRegistryKeyResponse responsePacket = new GetCreateRegistryKeyResponse(); string errorMsg; string newKeyName = ""; try { responsePacket.IsError = !(RegistryEditor.CreateRegistryKey(message.ParentPath, out newKeyName, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.Match = new RegSeekerMatch { Key = newKeyName, Data = RegistryKeyHelper.GetDefaultValues(), HasSubKeys = false }; responsePacket.ParentPath = message.ParentPath; client.Send(responsePacket); }
private void SetGroupPolicy(object sender, System.Windows.RoutedEventArgs e) { switch (SelectedPolicyOption.Key) { case ENABLE: RegistryEditor.DeleteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_AUOPTION); RegistryEditor.DeleteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_NOUPDATE); break; case DISABLE: RegistryEditor.WriteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_NOUPDATE, NOUPDATE_ENABLE, RegistryValueKind.DWord); RegistryEditor.DeleteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_AUOPTION); break; case NOTIFY_DOWNLOAD: RegistryEditor.WriteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_AUOPTION, AUOPTION_NOTIFY_DOWNLOAD, RegistryValueKind.DWord); RegistryEditor.DeleteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_NOUPDATE); break; case NOTIFY_INSTALL: RegistryEditor.WriteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_AUOPTION, AUOPTION_NOTIFY_INSTALL, RegistryValueKind.DWord); RegistryEditor.DeleteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_NOUPDATE); break; case SCHEDULE_INSTALL: RegistryEditor.WriteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_AUOPTION, AUOPTION_SCHEDULE_INSTALL, RegistryValueKind.DWord); RegistryEditor.DeleteLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_NOUPDATE); break; } Wu10Logger.LogInfo(string.Format("Group Policy set: {0}", SelectedPolicyOption.Value)); System.Windows.MessageBox.Show("Registry settings updated.", "Group Policies", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); }
private void RegisterDependencies() { DependencyManager.LogWriter = _logWriter; // Providers var configurationReader = new ConfigurationReader(); var credentialsProvider = new CredentialsProvider(); var fileIoProvider = new FileIoProvider(); var registryProvider = new RegistryProvider(); var userProvider = new UserProvider(); var windowsApiProvider = new WindowsApiProvider(); var windowsServiceProviderFactory = new WindowsServiceProviderFactory(); var powerShellProvider = new PowerShellProvider(); // Services var fileManager = new FileManager(fileIoProvider, windowsApiProvider, credentialsProvider); DependencyManager.FileManager = fileManager; DependencyManager.HostsFileEditor = new HostsFileEditor(fileIoProvider, configurationReader); var registryEditor = new RegistryEditor(windowsApiProvider, registryProvider, userProvider); DependencyManager.RegistryEditor = registryEditor; DependencyManager.WindowsServiceManager = new WindowsServiceManager(windowsServiceProviderFactory, registryEditor, fileManager, configurationReader); DependencyManager.WindowsPackageManager = new WindowsPackageManager(powerShellProvider, configurationReader); }
private void AddInstallInfoToRegistry() { UpdateStatus("Updating component registration..."); File.Copy(System.Windows.Forms.Application.ExecutablePath, installOptions.DestinationDirectory.Remove(installOptions.DestinationDirectory.Length - "\\Map Editor".Length) + "\\Installer.exe", true); RegistryEditor reg = new RegistryEditor(); reg.SetPath(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe Map Editor"); reg.Write("DisplayName", "Pokemon Mystery Universe Map Editor"); reg.Write("UninstallString", installOptions.DestinationDirectory.Remove(installOptions.DestinationDirectory.Length - "\\Map Editor".Length) + "\\Installer.exe" + " /Uninstall MapEditor"); reg.Write("HasRepair", "0"); reg.Write("NoModify", "1"); reg.Write("Publisher", "PMU Team"); reg.Write("DisplayIcon", installOptions.DestinationDirectory + "\\Graphics\\pmuicon.ico"); reg.Write("InstallPath", installOptions.DestinationDirectory); reg.Write("Installed", "1"); if (installOptions.InstallAllUsers) { reg.Write("AllUsers", "1"); } else { reg.Write("AllUsers", "0"); } }
static void Main() { RegistryEditor.RegisterWebBrowserVersion(IEVersion.LATEST); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new WebBrowserForm()); }
private void Form1_Shown(object sender, EventArgs e) { RegistryEditor regEdit = new RegistryEditor(); string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1 && File.Exists(args[1])) { loadUBMFile(args[1]); } else { string filePath = (string)regEdit.ReadFromRegistry("defaultFile", "Software\\UnityBuildManager", false, ""); if (filePath != "") { loadUBMFile(filePath); } } string unityPath = (string)regEdit.ReadFromRegistry("Location x64", "Software\\Unity Technologies\\Installer\\Unity", false, ""); if (unityPath == "") { string unityOurRegPath = (string)regEdit.ReadFromRegistry("unityPath", "Software\\UnityBuildManager", false, ""); if (unityOurRegPath == "") { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Unity Editor Executable | *.exe"; ofd.Title = "Select Unity Editor Executable"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { unityExec = ofd.FileName; regEdit.WriteToRegistry("unityPath", "Software\\UnityBuildManager", unityExec); } } else { unityExec = unityOurRegPath; } } else { unityExec = unityPath + "\\Editor\\Unity.exe"; if (File.Exists(unityExec)) { regEdit.WriteToRegistry("unityPath", "Software\\UnityBuildManager", unityExec); } } Process process = new Process(); ProcessStartInfo info = new ProcessStartInfo("Unity.exe", "Args"); }
public IEnumerable <bool> SetRegistryValues(IEnumerable <IRegistryRecord> registryRecords) { IList <bool> registryChangesResult = new List <bool>(); foreach (IRegistryRecord regRecord in registryRecords) { bool res = RegistryEditor.SetRegistryValue(regRecord); registryChangesResult.Add(res); } return(registryChangesResult); }
private int GetIntFromRegistryValue(string registryName) { var registryValue = RegistryEditor.ReadLocalMachineRegistryValue(UXRegistryKey, registryName); if (int.TryParse(registryValue, out var parsedValue)) { return(parsedValue); } else { return(0); } }
public MainWindow() { InitializeComponent(); amountOfWins = new AmountOfWins(); registryEditor = new RegistryEditor(Constants.gameRegistryPath); // form settings newNumberOfWins = amountOfWins.Get(); TextBoxNumberOfWins.Text = newNumberOfWins.ToString(); ComboBoxGravity.IsEnabled = false; ButtonApplyGravityHack.IsEnabled = false; UpdateListBoxSavesList(); }
private DateTime?GetDateFromRegistryValue(string registryName) { var registryValue = RegistryEditor.ReadLocalMachineRegistryValue(UXRegistryKey, registryName); if (DateTime.TryParse(registryValue, out var parsedValue)) { return(parsedValue); } else { return(null); } }
public void Uninstall() { RegistryEditor reg = new RegistryEditor(); string regPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe Map Editor"; reg.SetPath(regPath); if (reg.SubKeyExists()) //if (reg.Read("Installed") == "1") { { UpdateStatus("Found previous installed version, uninstalling..."); string path = reg.Read("InstallPath"); if (System.IO.Directory.Exists(path)) { System.IO.Directory.Delete(path, true); } bool installAllUsers; if (reg.Read("AllUsers") == "1") { installAllUsers = true; } else { installAllUsers = false; } string desktopPath; string startMenuPath; if (installAllUsers) { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonDesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonStartMenu); } else { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup); } if (System.IO.File.Exists(desktopPath + "\\PMU Map Editor.lnk")) { System.IO.File.Delete(desktopPath + "\\PMU Map Editor.lnk"); } if (System.IO.File.Exists(startMenuPath + "\\PMU Map Editor.lnk")) { System.IO.File.Delete(startMenuPath + "\\PMU Map Editor.lnk"); } reg.DeleteSubKey(); } }
void ShowStartupAppsFromSelectedComputersExecute(object param) { var dataToShow = new List <NodeItem>(); var computers = DomainComputers?.Where(x => x.IsSelected).ToList(); foreach (var computer in computers) { // Add ping here also using (_registryEditor = new RegistryEditor(computer?.Name, LookupSource, StartRemoteRegistryServiceIfNeeded)) { Dictionary <string, string> apps = null; try { apps = _registryEditor.GetAllStartupAppsFromRegistry(SkippableSource); } catch { } var data = apps?.Select(x => new KeyValuePair <string, string>(x.Key, x.Value)).ToList(); string name = string.Empty; if (data == null) { name = $"{computer?.Name} / (Not available)"; } else if (!data.Any()) { name = $"{computer?.Name} / NO EXTRA APPS"; } else { name = $"{computer?.Name}"; } dataToShow.Add(new NodeItem { ComputerName = name, Data = new ObservableCollection <KeyValuePair <string, string> >(data ?? new List <KeyValuePair <string, string> >()) }); } } var window = new StartupAppsWindow(); var viewModel = new StartupAppsWindowViewModel(dataToShow); window.DataContext = viewModel; window.Show(); }
private string GetNoUpdateStatus() { var nauValue = RegistryEditor.ReadLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_NOUPDATE); switch (nauValue) { case NOUPDATE_ENABLE: return(DISABLE); case NOUPDATE_DISABLE: default: return(ENABLE); } }
/// <summary> /// Create the web role coordinator. /// </summary> /// <param name="machineName">Specify the machineName if you would like to override the default machine name configuration.</param> public WebFarmRole(string machineName = null) { Log.Logger = AzureEnvironment.GetAzureLogger(); var config = AzureEnvironment.GetConfigSettings(); machineName = machineName ?? AzureEnvironment.GetMachineName(config); var octopusRepository = Infrastructure.OctopusDeploy.GetRepository(config); var processRunner = new ProcessRunner(); var registryEditor = new RegistryEditor(); _octopusDeploy = new Infrastructure.OctopusDeploy(machineName, config, octopusRepository, processRunner, registryEditor); AzureEnvironment.RequestRecycleIfConfigSettingChanged(config); }
public static string GetInstallPath() { RegistryEditor reg = new RegistryEditor(); string regPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe Client"; reg.SetPath(regPath); if (reg.SubKeyExists()) {//if (reg.Read("Installed") == "1") { string path = reg.Read("InstallPath"); if (System.IO.Directory.Exists(path)) { return path; } else { return null; } } return null; }
void ShowStartupAppsExecute(object param) { using (_registryEditor = new RegistryEditor(MachineName, LookupSource, startServiceIfNeeded: StartRemoteRegistryServiceIfNeeded)) { try { var result = _registryEditor.GetAllStartupAppsFromRegistry(SkippableSource); StartupApps = new ObservableCollection <KeyValuePair <string, string> >(result); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
static void Install(string targetPath) { "Installing...".WriteLine(ConsoleColor.Yellow, 1); var regEdit = new RegistryEditor(); try { regEdit.AddOrUpdateEntries(targetPath); "Done!".WriteLine(ConsoleColor.Yellow, 1); "You should now be able to right-click any Excel-compatible files and select 'Open in new window'. Enjoy! :)".WriteLineWait(); } catch (Exception e) { logger.Error(e, "Installation failed."); "Whoops!".WriteLine(ConsoleColor.Red, 1); "Sorry, but something unexpected happened. Installation failed. Please check the logs for more details.".WriteLineWait(); } }
void SetRegistryExecute(object param) { try { using (_registryEditor = new RegistryEditor(MachineName, LookupSource, StartRemoteRegistryServiceIfNeeded)) { _registryEditor.SetStartupAppToRegistry(RegistryKey, RegistryValue); } MessageBox.Show("Success !", "", MessageBoxButton.OK, MessageBoxImage.Information); RegistryKey = string.Empty; RegistryValue = string.Empty; } catch (Exception ex) { MessageBox.Show(ex.Message); } ShowStartupAppsExecute(null); }
private void setDefaultBtn_Click(object sender, EventArgs e) { if (pendingChanges) { promptSaveChanges(); } RegistryEditor regedit = new RegistryEditor(); if (loadedFileLbl.Text != "--") { regedit.WriteToRegistry("defaultFile", "Software\\UnityBuildManager", loadedFileLbl.Text); } else { regedit.WriteToRegistry("defaultFile", "Software\\UnityBuildManager", string.Empty); } }
private string GetAuOptionStatus() { var auValue = RegistryEditor.ReadLocalMachineRegistryValue(REGISTRY_ROOT, REGISTRY_AUOPTION); switch (auValue) { case AUOPTION_NOTIFY_DOWNLOAD: return(NOTIFY_DOWNLOAD); case AUOPTION_NOTIFY_INSTALL: return(NOTIFY_INSTALL); case AUOPTION_SCHEDULE_INSTALL: return(SCHEDULE_INSTALL); default: return(ENABLE); } }
public static void HandleDeleteRegistryKey(DoDeleteRegistryKey packet, Networking.Client client) { GetDeleteRegistryKeyResponse responsePacket = new GetDeleteRegistryKeyResponse(); string errorMsg; try { responsePacket.IsError = !(RegistryEditor.DeleteRegistryKey(packet.KeyName, packet.ParentPath, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.ParentPath = packet.ParentPath; responsePacket.KeyName = packet.KeyName; client.Send(responsePacket); }
public static void HandleDeleteRegistryKey(xLightClient.Core.Packets.ServerPackets.DoDeleteRegistryKey packet, Client client) { xLightClient.Core.Packets.ClientPackets.GetDeleteRegistryKeyResponse responsePacket = new Packets.ClientPackets.GetDeleteRegistryKeyResponse(); string errorMsg = ""; try { responsePacket.IsError = !(RegistryEditor.DeleteRegistryKey(packet.KeyName, packet.ParentPath, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.ParentPath = packet.ParentPath; responsePacket.KeyName = packet.KeyName; responsePacket.Execute(client); }
public static void HandleChangeRegistryValue(xLightClient.Core.Packets.ServerPackets.DoChangeRegistryValue packet, Client client) { xLightClient.Core.Packets.ClientPackets.GetChangeRegistryValueResponse responsePacket = new Packets.ClientPackets.GetChangeRegistryValueResponse(); string errorMsg = ""; try { responsePacket.IsError = !(RegistryEditor.ChangeRegistryValue(packet.Value, packet.KeyPath, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.KeyPath = packet.KeyPath; responsePacket.Value = packet.Value; responsePacket.Execute(client); }
public static void HandleDeleteRegistryValue(Paketler.ServerPaketleri.DoDeleteRegistryValue packet, Client client) { Paketler.ClientPaketleri.GetDeleteRegistryValueResponse responsePacket = new Paketler.ClientPaketleri.GetDeleteRegistryValueResponse(); string errorMsg = ""; try { responsePacket.IsError = !(RegistryEditor.DeleteRegistryValue(packet.KeyPath, packet.ValueName, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.ValueName = packet.ValueName; responsePacket.KeyPath = packet.KeyPath; responsePacket.Execute(client); }
private void Execute(ISender client, DoChangeRegistryValue message) { GetChangeRegistryValueResponse responsePacket = new GetChangeRegistryValueResponse(); string errorMsg; try { responsePacket.IsError = !(RegistryEditor.ChangeRegistryValue(message.Value, message.KeyPath, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.KeyPath = message.KeyPath; responsePacket.Value = message.Value; client.Send(responsePacket); }
public static string GetInstallPath() { RegistryEditor reg = new RegistryEditor(); string regPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe Map Editor"; reg.SetPath(regPath); if (reg.SubKeyExists()) //if (reg.Read("Installed") == "1") { { string path = reg.Read("InstallPath"); if (System.IO.Directory.Exists(path)) { return(path); } else { return(null); } } return(null); }
private void Execute(ISender client, DoDeleteRegistryKey message) { GetDeleteRegistryKeyResponse responsePacket = new GetDeleteRegistryKeyResponse(); string errorMsg; try { responsePacket.IsError = !(RegistryEditor.DeleteRegistryKey(message.KeyName, message.ParentPath, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.ParentPath = message.ParentPath; responsePacket.KeyName = message.KeyName; client.Send(responsePacket); }
public static void HandleChangeRegistryValue(DoChangeRegistryValue packet, Networking.Client client) { GetChangeRegistryValueResponse responsePacket = new GetChangeRegistryValueResponse(); string errorMsg; try { responsePacket.IsError = !(RegistryEditor.ChangeRegistryValue(packet.Value, packet.KeyPath, out errorMsg)); } catch (Exception ex) { responsePacket.IsError = true; errorMsg = ex.Message; } responsePacket.ErrorMsg = errorMsg; responsePacket.KeyPath = packet.KeyPath; responsePacket.Value = packet.Value; client.Send(responsePacket); }
static void UnInstall() { "Uninstalling...".WriteLine(ConsoleColor.Yellow, 1); var regEdit = new RegistryEditor(); try { regEdit.RemoveEntries(); "Done!".WriteLine(ConsoleColor.Yellow, 1); "ExcelLaunchPad has been uninstalled. You may now delete all ExcelLaunchPad files from your computer.".WriteLineWait(); } catch (Exception e) { logger.Error(e, "UnInstall failed."); "Whoops!".WriteLine(ConsoleColor.Red, 1); "Sorry, but something unexpected happened. ExcelLaunchPad was not removed. Please check the logs for more details.".WriteLineWait(); } }
public void Uninstall() { RegistryEditor reg = new RegistryEditor(); string regPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe Client"; reg.SetPath(regPath); if (reg.SubKeyExists()) {//if (reg.Read("Installed") == "1") { UpdateStatus("Found previous installed version, uninstalling..."); string path = reg.Read("InstallPath"); if (System.IO.Directory.Exists(path)) { System.IO.Directory.Delete(path, true); } bool installAllUsers; if (reg.Read("AllUsers") == "1") { installAllUsers = true; } else { installAllUsers = false; } string desktopPath; string startMenuPath; if (installAllUsers) { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonDesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonStartMenu); } else { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup); } if (System.IO.File.Exists(desktopPath + "\\Pokemon Mystery Universe.lnk")) { System.IO.File.Delete(desktopPath + "\\Pokemon Mystery Universe.lnk"); } if (System.IO.File.Exists(startMenuPath + "\\Pokemon Mystery Universe.lnk")) { System.IO.File.Delete(startMenuPath + "\\Pokemon Mystery Universe.lnk"); } reg.DeleteSubKey(); } // Uninstall the version installed by the old installer regPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe"; reg.SetPath(regPath); if (reg.SubKeyExists()) {//if (reg.Read("Installed") == "1") { UpdateStatus("Found previous installed version, uninstalling..."); string path = reg.Read("InstallPath"); if (System.IO.Directory.Exists(path)) { System.IO.Directory.Delete(path, true); } bool installAllUsers; if (reg.Read("AllUsers") == "1") { installAllUsers = true; } else { installAllUsers = false; } string desktopPath; string startMenuPath; if (installAllUsers) { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonDesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonStartMenu); } else { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup); } if (System.IO.File.Exists(desktopPath + "\\Pokemon Mystery Universe.lnk")) { System.IO.File.Delete(desktopPath + "\\Pokemon Mystery Universe.lnk"); } if (System.IO.File.Exists(startMenuPath + "\\Pokemon Mystery Universe.lnk")) { System.IO.File.Delete(startMenuPath + "\\Pokemon Mystery Universe.lnk"); } reg.DeleteSubKey(); } }
private void AddInstallInfoToRegistry() { UpdateStatus("Updating component registration..."); File.Copy(System.Windows.Forms.Application.ExecutablePath, installOptions.DestinationDirectory.Remove(installOptions.DestinationDirectory.Length - "\\Client".Length) + "\\Installer.exe", true); RegistryEditor reg = new RegistryEditor(); reg.SetPath(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\Pokemon Mystery Universe Client"); reg.Write("DisplayName", "Pokemon Mystery Universe Client"); reg.Write("UninstallString", installOptions.DestinationDirectory.Remove(installOptions.DestinationDirectory.Length - "\\Client".Length) + "\\Installer.exe" + " /Uninstall Client"); reg.Write("HasRepair", "0"); reg.Write("NoModify", "1"); reg.Write("Publisher", "PMU Team"); reg.Write("DisplayIcon", installOptions.DestinationDirectory + "\\pmuicon.ico"); reg.Write("InstallPath", installOptions.DestinationDirectory); reg.Write("Installed", "1"); if (installOptions.InstallAllUsers) { reg.Write("AllUsers", "1"); } else { reg.Write("AllUsers", "0"); } }