private void DeleteRegistry() { AutoHelpers.LogInvariant("Deleting registry node: {0}", regNode); string deleteCmd = AutoHelpers.FormatInvariant(regDelCommand, regNode); Process regProc = Process.Start(regExePath, deleteCmd); regProc.WaitForExit(); }
public void CreateTempCmdShortcut() { string tempPath = Path.Combine(Path.GetTempPath(), AutoHelpers.FormatInvariant("{0}.lnk", Path.GetRandomFileName())); AutoHelpers.LogInvariant("Creating temporary shortcut: {0}", tempPath); Shell32.IShellLinkW link = (Shell32.IShellLinkW) new Shell32.ShellLink(); link.SetDescription("Created by Conhost.UIA.Tests.Common.ShortcutHelper"); link.SetPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe")); Shell32.IPersistFile persist = (Shell32.IPersistFile)link; // performs QI persist.Save(tempPath, false); this.ShortcutPath = tempPath; }
public void RestoreRegistry() { AutoHelpers.LogInvariant("Restore settings to pre-test status."); this.DeleteRegistry(); AutoHelpers.LogInvariant("Restoring registry from file: {0}", backupFile); Verify.IsTrue(File.Exists(backupFile)); string restoreCmd = AutoHelpers.FormatInvariant(regLoadCommand, backupFile); Process regProc = Process.Start(regExePath, restoreCmd); regProc.WaitForExit(); File.Delete(backupFile); this.backupFile = null; }
public void BackupRegistry() { AutoHelpers.LogInvariant("Save existing registry key status."); this.backupFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); AutoHelpers.LogInvariant("Backing up registry to file: {0}", backupFile); Verify.IsFalse(File.Exists(backupFile)); string backupCmd = AutoHelpers.FormatInvariant(regSaveCommand, regNode, backupFile); AutoHelpers.LogInvariant("Calling command: {0} {1}", regExePath, backupCmd); Process regProc = Process.Start(regExePath, backupCmd); regProc.WaitForExit(); Verify.IsTrue(File.Exists(backupFile)); }
public void SetDefaultValue(string valueName, object valueValue) { AutoHelpers.LogInvariant("Setting registry key {0}'s value name {1} to value {2}", regNode, valueName, valueValue); Registry.SetValue(regNodeVerbose, valueName, valueValue); }