开发者

Automatic program update and Windows 7

We have a suite of programs that check for new versions at startup, and then download new versions to run if required. This is obviously a problem in Windows 7, when it is locked down as a 'standard user', as they can't write to the c:\program files directory and below. Anyone seen a example of an application that gets around with issue ?

Ou开发者_运维问答r applications are written in Delphi, but an example in any language would be useful.

Thanks in advance

Update:

We already have a system for determing whether a new version exists, the only problem is the download and install (if required), as this requires elevation. I can't think of a way that doesn't require an elevation prompt, or our users to reduce their security settings.

Update 2 :

I've asked a subsequent question, rather than adding a new one here


There are two options for application installation:

  1. Application is available for all users: installation or update requires elevation for Windows Vista and up
  2. The application is available for one user: install or update the application in the user profile in %LOCALAPPDATA%, no elevation is required

Ad 2: Google Chrome does this. It installs the .exe here:

%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe

--jeroen


Typically what you will see an application do if it needs to escalate permissions is something like this.

  1. Application determines if upgrade is needed
  2. Application launches an "updater" service that requires "Administrator" permissions
  3. Application updates itself with this updated
  4. Application re-starts

This is a pretty common scenario, especially since to update your own DLL you need to go to a secondary process anyway.


Here are some tips for you to get around updating challenges:

  1. If your file is names 'update.exe' or 'install.exe' then it will automatically force a UAC elevation prompt. This is an easy way to make existing software bypass Windows Vista/7 permissions.
  2. It is not a good idea to have the update checking and update process managed from within your application. The problem is that your app is likely to lock files and need updating itself. An external app should manage your updates.
  3. The simplest update solution is to make an HTTP call that checks for the current product version number, and then download the installer binary if necessary. This won't give you any flexibility in updates, but it is a quick and easy solution.

Our company sells software that specifically helps with automatic updates on Windows 7 UAC (you can visit AutoUpdate+ by clicking here: link text). The best reasons for using a third party solution - any solution - are that you will have more flexibility with your updates and also avoid the finicky challenges of supporting different Windows releases.


Or you can have it so that the user runs a launcher app.

  1. The application uses the LOCALAPPPATH\ folder to store a cache of the main application.
  2. Launcher checks to see if the internet has newer version of file(s) than the cached file.
  3. Launcher launches the cached application in LOCALAPPPATH


Your app can check if a new version is available on the remote server. If it does, then it can download update files in one of user-specific folders, like user's temp folder. You can get address of such special folders using SHGetSpecialFolder API function.

Once the download is done, you can pop up a dialog box telling user that you are ready for update. If user agrees with update, then you can run the updater process with elevated privileges (as administrator), and updater process can replace existing files in your installation path with the ones already downloaded in user Temp folder. To run your updater as administrator, you can use ShellExecute:

ShellExecute(0,'runas','notepad.exe',nil,nil,SW_SHOWNORMAL);

When updating is done, your updater process can restart your app.


You need to have a separate executable to the updating work. The updater needs to have a manifest that marks it as requiring elevation.

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


If your application uses MSI (Windows Installer) for its installer, then User Account Control Patching, if properly configured, can let you install updates without elevation.


  1. If your installer wasn't run under admin - you don't need any additional rights to install update.

  2. If your installer was run under admin - then it can create a task in Task Sheduler. Say, run this task once a week, under this account (admin) and with highest privs. Task will be your updater. Simple.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜