c# on windows updating a program while it's st

2019-05-30 14:50发布

问题:

I have a program on a kiosk with an associated service that updates the program by periodically checking on the web for a newer version of the MSI. If it finds one, it will install it, the program may still be running.

To get around the DLL conflicts of the above solution, I rename the assemblies in the MSI with by version so a new version can install while the old is running. The application will poll the install directory for newer version assemblies and if it finds one restart as soon as it is not being used. Are there any better ways to do this?

回答1:

I've done this story before. It works like this:

The UI is running as the logged on User.

The service is running as System. The service checks for content and downloads it to a temp directory. It then advertises the MSI using the /JM command. The installer can now be installed by the non-priviledged user.

The service sends an IPC message to the application saying that it's time to install. The application kicks off the installer passing it a flag that indicates to restart the application. The application the quits releasing the locked files.

At the end of the installer the flag causes the installer to relaunch the application.

Also take a look at the wuw4 library. It helps in creating a lot of this solution.



回答2:

Wouldn't ClickOnce be a better option here?

http://msdn.microsoft.com/en-us/library/t71a733d.aspx