我试图在Windows 7中以编程方式启用/禁用系统还原。我已启用系统还原工作" enable -ComputerRestore",但禁用给我带来了问题。
Disable-ComputerRestore -drive "C:\"没有将我的C:盘设置为“关闭系统保护”。它将其设置为“仅恢复以前版本的文件”。有谁知道为什么会发生这样的事情?
发布于 2011-12-26 04:25:21
我正在使用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);
}
}发布于 2011-12-23 16:23:33
您只需以管理员身份在本地(无远程)执行此操作:

该命令

请注意,您必须关闭系统属性windo,然后重新打开它才能看到结果。

https://stackoverflow.com/questions/8612654
复制相似问题