Справочник по C#

    Исходники по языку программирования CSharp

    Включение/отключение “Восстановление системы” Windows : Справочник по C#

    /
    /
    /
    36 Views


    Способ 1:
    RegistryKey rk = Registry.LocalMachine;
    RegistryKey rk1 = rk.OpenSubKey(@"SOFTWAREMicrosoftWindows NTCurrentVersionSystemRestore");
    string sysRestore = rk1.GetValue("RPSessionInterval").ToString();
    if (sysRestore.Contains("1"))
    {
    MessageBox.Show("System Restore is Enabled");
    }
    
    if (sysRestore.Contains("0"))
    {
    MessageBox.Show("System Restore is Disabled");
    }
    

    Способ 2:

    string osDrive = Path.GetPathRoot(Environment.SystemDirectory);
    
    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("Enable");
    inParams["WaitTillEnabled"] = true;
    inParams["Drive"] = osDrive;
    ManagementBaseObject outParams = process.InvokeMethod("Enable", inParams, null);
    

    Включение/отключение “Восстановление системы” Windows : Справочник по C#

    0.00 (0%) 0 votes

    moyadcode13
    • Facebook
    • Twitter
    • Google+
    • Linkedin
    • Pinterest
    moyadcode10
    moyadcode11
    moyadcode9