【问题标题】:Disable-ComputerRestore doesn't turn off system protectionDisable-ComputerRestore 不会关闭系统保护
【发布时间】:2012-01-26 14:42:23
【问题描述】:

我正在以编程方式尝试在 Windows 7 中启用/禁用系统还原。我已启用系统还原工作“Enable-ComputerRestore”,但禁用会给我带来问题。

Disable-ComputerRestore -drive "C:\"

没有将我的 C: 驱动器设置为“关闭系统保护”。而是将其设置为“仅恢复以前版本的文件”。任何人都知道为什么会发生这种情况?

【问题讨论】:

    标签: windows windows-7 powershell wmi


    【解决方案1】:

    您只需以管理员身份在本地(无需远程)执行:

    命令

    小心,你必须关闭系统属性窗口并重新打开它才能看到结果。

    【讨论】:

    • 是的,我在本地进行,并且以管理员身份进行。这是之前的截图:link。这是之后的截图:link.
    • 我通过手动选择一次“仅恢复以前版本的文件”来重现您的麻烦!
    • 这是某种错误吗?我很困惑该怎么做。我正在使用 C# 和 WMI 尝试一些事情,但我没有任何运气。
    【解决方案2】:

    我正在使用 WMI 和以下改编自 here 的 C# 代码解决此问题。

        public void disableSystemRestore(string drive)
        {
            try
            {
                ManagementScope scope = new ManagementScope("\\\\localhost\\root\\default");
                ManagementPath path = new ManagementPath("SystemRestore");
                ObjectGetOptions options = new ObjectGetOptions();
                ManagementClass process = new ManagementClass(scope, path, options);
                ManagementBaseObject inParams = process.GetMethodParameters("Disable");
                inParams["Drive"] =  drive;
                ManagementBaseObject outParams = process.InvokeMethod("Disable", inParams, null);
            }
            catch(ManagementException err)
            {
                MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2012-10-17
      • 1970-01-01
      • 2012-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多