How to find out if an MSI I just installed requested a Windows reboot?

前端 未结 3 1689
别跟我提以往
别跟我提以往 2020-12-18 00:53

I\'ve built a setup.exe in C# that runs several chained MSI\'s (with the /QUIET /NORESTART). At the end I\'d like to check if a reboot is needed in

3条回答
  •  失恋的感觉
    2020-12-18 01:03

    Another way to accomplish this is to check the exit codes of all of the MSIs that you run in your code. If an MSI has an exit code of 3010 then it requires a reboot. (http://msdn.microsoft.com/en-us/library/aa368542.aspx).

    Assuming that you're using System.Diagnostics.Process to run the MSIs and after the process has exited, you would retrieve the processes exit code using the ExitCode property (http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exitcode(v=vs.90).aspx).

    So, you can simply check the exit code of an MSI process and when you're done running all of your MSIs, if any of them returned 3010 then you know you need to reboot.

提交回复
热议问题