protected override void BeginProcessing() { Type = Item.CheckCase(Type); Inherited = Item.CheckCase(Inherited); if (Chroot != null) { string keyName = RegistryPath.Substring(RegistryPath.IndexOf("\\") + 1); RegistryPath = System.IO.Path.Combine(Chroot, keyName); } _generator = new TestGenerator(Test); }
protected override void ProcessRecord() { // 管理者実行確認 Functions.CheckAdmin(); using (RegistryKey regKey = RegistryControl.GetRegistryKey(RegistryPath, false, false)) { if (regKey != null) { return; } } // テスト自動生成 _generator.RegistryPath(RegistryPath); string keyName = RegistryPath.Substring(RegistryPath.IndexOf("\\") + 1); RegistryHive.Load(keyName, DatFile); // ロード成功確認 using (RegistryKey regKey = RegistryControl.GetRegistryKey(RegistryPath, false, false)) { if (regKey != null) { WriteObject(new RegistrySummary(regKey)); return; } } // ロード失敗時の再ロード用コマンド using (Process proc = new Process()) { proc.StartInfo.FileName = "reg.exe"; proc.StartInfo.Arguments = $"load \"{RegistryPath}\" \"{DatFile}\""; proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.Start(); proc.WaitForExit(); } using (RegistryKey regKey = RegistryControl.GetRegistryKey(RegistryPath, false, false)) { if (regKey != null) { WriteObject(new RegistrySummary(regKey)); } } }