C#创建还原点netframework 3.5
是否可以从netframework 3.5目标中的C#创建一个还原点以及所有必需的任务(启用系统保护、调整阴影存储大小)? 我找到了一些示例,但它们都使用System.Management.Automation来执行netframework 3.5中没有的powshershell脚本。C#创建还原点netframework 3.5,c#,restore-points,C#,Restore Points,是否可以从netframework 3.5目标中的C#创建一个还原点以及所有必需的任务(启用系统保护、调整阴影存储大小)? 我找到了一些示例,但它们都使用System.Management.Automation来执行netframework 3.5中没有的powshershell脚本。 我试图做的是在gui中的一个按钮上绑定整个操作(如果禁用,则启用系统还原,调整shadowstorage的大小并创建还原点)。以下是使用WMI的winforms代码,请欣赏: 您始终可以使用进程运行PowerSh
我试图做的是在gui中的一个按钮上绑定整个操作(如果禁用,则启用系统还原,调整shadowstorage的大小并创建还原点)。以下是使用WMI的winforms代码,请欣赏:
您始终可以使用
进程运行PowerShell。与所需的任何脚本一起运行。
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class CallWMIMethod
{
public new static int Main()
{
try
{
ManagementObject classInstance = new ManagementObject(@"root\DEFAULT", "SystemRestore.ReplaceKeyPropery='ReplaceKeyPropertyValue'", null);
// Obtain [in] parameters for the method
ManagementBaseObject inParams = classInstance.GetMethodParameters("CreateRestorePoint");
// Add the input parameters.
// Execute the method and obtain the return values.
ManagementBaseObject outParams = classInstance.InvokeMethod("CreateRestorePoint", inParams, null);
// List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: {0}", outParams("ReturnValue"));
}
catch (ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
}
}
}