bari eune
bari eune

Reputation: 23

Looking for strategies to check if a system has been restarted

I am writing an installer for my application. This installer needs to install various components and some of them require a system reboot before the next component has been installed.

The user has the option to deny a restart and do it on their own later, which is where I'm hitting a wall at the moment.

I've first considered creating some lock file or a registry entry, which on the surface level sounds doable, however if the user denies a restart and reboots at a later time through whatever way, then the registry object / file aren't deleted. Which means that when the user restarts my installer, then the installer has no way to know whether the system has been restarted or not.

My next idea was to use .NET's System.Threading.Mutex, which I thought would persist in memory after my installer processes has been finished, which was a naive approach because the mutex is cleared from the system when the reference count is reduced to 0. This would imply I need to fork another process which remains in memory holding that mutex until the user either kills the process or restarts. This seems like a bad idea...

Are there any short and sweet strategies that people use to achieve this sort of thing?

Haven't found any relevant articles here either by the way. I need some type of lock object or in memory object that persists beyond my application's lifetime but also only until the system has been rebooted.

Upvotes: 0

Views: 40

Answers (0)

Related Questions