How can a required reboot be detected for Windows 7

后端 未结 3 1858
梦如初夏
梦如初夏 2020-12-10 04:43

I am working on a project where several software and drivers are installed on a windows 7 PC. This shall work without user inputs.

Now there is the question: How can

3条回答
  •  误落风尘
    2020-12-10 04:56

    After a long research I found a way how to query pending restarts with a native Windows DLL directly in a .NET application. The main problem is that there can be many reasons why Windows has to restart. In addition, the Windows version sometimes also plays a role.

    During the research I came across an article describing various scripts in the Windows Update environment, such as determining whether the automatic updates service is enabled or a computer needs to be rebooted. There you will find a reference to the Microsoft.Update.SystemInfo Object, which finally led to ISystemInformation interface having the method ISystemInformation::get_RebootRequired (Gets a Boolean value that indicates whether a system restart is required to complete the installation or uninstallation of one or more updates.).

    For more details about the journey, see my blog post Determine programmatically pending reboot status for a Windows machine in C# and PowerShell

提交回复
热议问题