Pergunta

Google's Chrome browser has a super-slick updating system on Windows. It doesn't require administrative privileges, and it updates in place without requiring user interaction.

I'm trying to create something similar to this, and would appreciate any advice on how to do it.

The first part of their trick is they don't install into Program Files like most Windows programs do, instead they install into C:\Users\USER_NAME\AppData\Local\Google\Chrome\Application. This enables their program file to modify itself without administrative privileges.

Looking inside that directory, I see that there is not only a chrome.exe but also an old_chrome.exe. Searching around online, I've found that chrome backs itself up as old_chrome in case the update goes bad, it can still run something.

So is the way to do this to create a helper application that comes as part of the install package, that you transfer execution into (I assume that's somehow doable), and that helper application does the file renaming and relaunches chrome.exe when it's done? (If so, assumedly this helper application is in turn deleted by chrome.exe on launch, explaining why I don't see it sitting around.) There's no way to simply have chrome.exe rename itself to old_chrome.exe and copy in and launch the new chrome.exe is there?

If this is the best way to make something like this work, are there any pre-built solutions to do this that I could just roll into my project, given that this seems like fairly generic functionality, or would I have to roll something like this myself?

Alternatively, if there's a better way, what is it? (For what it's worth, Chrome's approach strikes me as much more elegant and straightforward than Mozilla's new approach using services)

Foi útil?

Solução

Okay, got this working, here's how it works.

There's no need for a helper application. At least on Windows, a program can be renamed in place, it just can't be deleted. Therefore, I added an updater routine to my program, and it downloads the new file. After download is complete, it renames the old executable, and moves the new executable into its spot.

Then, you can simply execute the new executable from inside the old one's running process, and then quit the old one.

Voila, no-escalation swap of a new version for the old.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top