File:  [cleanflash] / cleanflash / CleanFlashCommon / RegistryManager.cs
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Oct 13 09:04:22 2021 UTC (4 years, 7 months ago) by root
Branches: UNKNWN, MAIN
CVS tags: v3400192, HEAD
cleanflash 34.0.0.192

using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace CleanFlashCommon {
    public class RegistryManager {

        public static void ApplyRegistry(string registryContents) {
            registryContents = "Windows Registry Editor Version 5.00\n\n" + SystemInfo.FillString(registryContents);
            string filename = Path.GetTempFileName();

            File.WriteAllText(filename, registryContents, Encoding.Unicode);

            Directory.SetCurrentDirectory(Path.GetDirectoryName(filename));

            ExitedProcess process = ProcessRunner.RunProcess(
                new ProcessStartInfo {
                    FileName = "reg.exe",
                    Arguments = "import " + Path.GetFileName(filename),
                    UseShellExecute = false,
                    CreateNoWindow = true
                }
            );

            File.Delete(filename);

            if (!process.IsSuccessful) {
                throw new InstallException(string.Format("Failed to apply changes to registry: error code {0}\n\n{1}", process.ExitCode, process.Output));
            }
        }

        public static void ApplyRegistry(List<string> registryContents) {
            ApplyRegistry(string.Join("\n\n", registryContents));
        }

        public static void ApplyRegistry(params string[] registryContents) {
            ApplyRegistry(string.Join("\n\n", registryContents));
        }
    }
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.