Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

windows installer - At each login the program tries to configure installation parameters in the HKEY_LOCAL_MACHINE registry

After a program was installed by an admin user, different users with no admin rights experience the following problem with their logins to the same computer.

At the installation of the program by an admin user, a generic connection information to a SQL database is written to a key in HKEY_LOCAL_MACHINE registry once (eg. (local)sqlexpress). Then this information in the registry is manually modified by the admin for the relevant database connection information (eg. Remote_locationsqlexpress). So this information is machine specific, not user specific so that the program will work and fetch the data from the database for each user.

After the installation, several users (non-admin) log in to the computer to run the program:

  1. User 1 logs in and the program works fine, it accesses the database. Then logs out and logs back in again, and the program works fine the next time.

  2. Then user 2 logs in and starts the program. A message box pops up and it says “Please wait while Windows configures the Program” and it fails to connect to the database because the re-configuration has overwritten the database connection with the generic database connection data in the registry, so that the program cannot find database.

  3. So we import the database settings to the registry and restart the program and it connects fine to the database. The user logs out and logs back in and the program works.

  4. Then user 1 logs back in and the program does not work with the same message “Please wait while Windows configures the Program” even though it was already working and running previously with user 1.

It seems the program will only work for one user! How can we resolve this? Why is Windows trying to re-install the program each time a different user tries to login although the information for the program to connect to the database is in the common machine location in the registry?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Basically you cannot install a KeyPath registry item that is going to be changed by the user, for the simple reason that Windows Installer will believe it is broken and repair it.

The simplest cure is to give that component (in your WiX) a null component ID. As the documentation her says, under ComponentId:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa368007(v=vs.85).aspx

a component with a null id is not registered and not subject to repair.

You should also verify what the actual missing component is by looking at the Windows Event log, Application, and look for MsiInstaller entries that will refer to the broken or missing component. There might really be another component that appears to be broken, such as another file or registry entry. If this is the case then the repair of the HKLM registry item could be a downstream effect because when a component is repaired Windows will repair and reinstall the entire feature, and that could include the HKLM entry. Either way, it is not safe to have an HKLM entry (registered with MSI) that can be altered because there are other scenarios (such as repair from Programs&Features or right click the MSI file) that could rewrite the registry entry. However the main point is that a repair will replace that registry entry.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...