如何在用户登录到应用程序时创建系统还原点,并在从winforms C#应用程序注销时通过该还原点重置PC?

如何在用户登录到应用程序时创建系统还原点,并在从winforms C#应用程序注销时通过该还原点重置PC?,c#,winforms,kiosk,C#,Winforms,Kiosk,我已尝试使用以下代码创建还原点,但它在windows 10中不起作用: 有没有其他解决办法?如果可能,请提供示例 public static bool CreateRestorePoint(string description) { bool isCreated = true; try { ManagementScope oScope = new Managem

我已尝试使用以下代码创建还原点,但它在windows 10中不起作用: 有没有其他解决办法?如果可能,请提供示例

        public static bool CreateRestorePoint(string description)
        {
            bool isCreated = true;
            try
            {
                ManagementScope oScope = new ManagementScope("\\\\localhost\\root\\default");
                ManagementPath oPath = new ManagementPath("SystemRestore");
                ObjectGetOptions oGetOp = new ObjectGetOptions();
                ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);

                ManagementBaseObject oInParams =
                     oProcess.GetMethodParameters("CreateRestorePoint");
                oInParams["Description"] = description;
                oInParams["RestorePointType"] = 12; // MODIFY_SETTINGS
                oInParams["EventType"] = 100;

                ManagementBaseObject oOutParams =
                     oProcess.InvokeMethod("CreateRestorePoint", oInParams, null);
            }
            catch (Exception)
            {
                isCreated = !isCreated;
            }
            return isCreated;
        }