Vb.net 检查VB中的重新启动挂起状态
在我正在编写的VB程序中应用Microsoft修补程序后,我正在尝试确定计算机是否处于“等待重新启动”状态。 我有以下资料:Vb.net 检查VB中的重新启动挂起状态,vb.net,registry,Vb.net,Registry,在我正在编写的VB程序中应用Microsoft修补程序后,我正在尝试确定计算机是否处于“等待重新启动”状态。 我有以下资料: Private Sub DoesKeyExist() Dim regKey As Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Windo
Private Sub DoesKeyExist()
Dim regKey As Microsoft.Win32.RegistryKey
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired", True)
If regKey Is Nothing Then
MsgBox("No reboot pending.")
Else
MsgBox("Reboot is pending")
End If
End Sub
但是,这不起作用,每次都不返回任何内容。有什么建议吗?感谢您使用.LocalMachine。您已在HKEY_LOCAL_机器中搜索的零件。尝试使用
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired", True)
相反。事实上,我一提交并更改它,就发现它仍在做同样的事情。找到了解决方案!Private Sub DoesKeyExist()Dim regKey As Object regKey=My.Computer.Registry.LocalMachine.GetValue(“软件\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update”,“RebootRequired”,Nothing)如果regKey为Nothing,则MsgBox(“无重新启动挂起”)否则MsgBox(“重新启动挂起”)如果End SubYes,则结束。我说得太快了。显然,它只是将“RebootRequested”作为值传递,而不是实际检查。