1

私は現在、Windows 8で「アップデートを自動的にインストールする」の代わりに「インストールするかどうかを選択させる」にWindowsアップデートを設定する方法を理解しようとしています。

Check from .NET if Windows Update is enabledによると、次のことを試しました。

WUApiLib.AutomaticUpdatesClass auc = new WUApiLib.AutomaticUpdatesClass();
// Doing some stuff

ただし、次のエラーが発生します。
Interop type 'WUApiLib.AutomaticUpdatesClass' cannot be embedded. Use the applicable interface instead.

The type 'WUApiLib.AutomaticUpdatesClass' has no constructors defined

Powershellでwindows update設定を変更するの回答に従って、次のことを行いました。

string subKey = @"SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU";
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKey, true))
    key.SetValue("AUoptions", 4);

しかし、サブキーがレジストリに存在しないため、Reference not set to an instance of an objectエラーが発生します。

Google の残りの結果はすべて、この設定を手動で変更する方法を説明していますが、これは私が探しているものではありません。

プログラムで Windows Update を "インストールするかどうかを選択できるようにする" ように設定するにはどうすればよいですか?

4

2 に答える 2