好的,我正在尝试提取一个注册表条目,但它不起作用,每次我尝试它都会拉出一个空值。我尝试以管理员身份运行单个 exe 以仔细检查权限。我创建了一个执行相同功能的批处理文件,它运行良好,我还使用相同的方法在脚本的其他部分提取注册表值,但似乎找不到问题。程序运行良好并显示 0 个错误。
源代码:
' Check Auto Update settings
Dim AUOptions_Value = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "AUOptions", Nothing)
Dim AUOptions_level
If AUOptions_Value = 4 Then
AUOptions_level = "Auto Update Options set to: Install Updates Automatically."
Display_AUOptions.ForeColor = Color.Green
ElseIf AUOptions_Value = 3 Then
AUOptions_level = "Download Updates but let me choose whether to install them."
Display_AUOptions.ForeColor = Color.Blue
ElseIf AUOptions_Value = 2 Then
AUOptions_level = "Check for updates but let me choose whether to download them and install them."
Display_AUOptions.ForeColor = Color.Blue
ElseIf AUOptions_Value = 1 Then
AUOptions_level = "Never check for updates."
Display_AUOptions.ForeColor = Color.Red
Else
AUOptions_level = "Unable to detect settings"
Display_AUOptions.ForeColor = Color.Red
End If
Display_AUOptions.Text = AUOptions_level
End Sub
注册表项:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update]
"AUOptions"=dword:00000004