How to find locked binaries
as part of upgrade/fresh installation?
When you upgrade an
application using windows installer many a time you might have come across issues like the
files which you wanted to overwrite or delete is already in use or in another way
some other application is already using that binary. In such cases, the windows installer
will show a FilesInUse dialog. However, the problem here is this dialog will
show only the application name which is consuming the binary and not the actual
binary name. This has 2 problems, in case of a simple application which a handful
of binaries we can easily figure out the binary getting locked, however in case
of a large application with several binaries and run times it might be tricky to
find out such locked binaries. The problem gets even more complicated if this
scenario occurs in an environment where you don't have access, for example, a
customer environment.
Let me briefly
explain how installer identifies and shows the application which is consuming
our binaries. As part of the install costing process, installer identifies the
files which are in use and it populates an internal "FilesInUse"
table. As part of the InstallValidate custom action, this table will be queried
and the information will be shown in msiRMFileInUse dialog. I have done a lot
of google search and I couldn't find a way to extract the file in use
information from "FilesInUse" table. Having said that, you can use
the below tools to find this,
- To check which application is consuming your dll, you can use the Sysinternals utility "Listdlls" and here is the command listdlls -r -d <dll name>
- You can run the utility without any parameters and it will dump all the application and its loaded dlls
Sometimes listdlls
utility will not find the locked dlls and in that case you can use handle.exe
which is another sysinternal utility to find out if somebody has a handle to
that binary/file
For example
handle.exe <full path to the binary>
If both the above
fails, another option is to use procmon utility to find out what is happening
with the installer and this can give you some clue. As you can see in the below
screenshot, the installer is trying to write something to the highlighted registry
key (HKEY_CURRENT_USER\Software\Microsoft\RestartManager\Session0000\RegFiles0000) and this key contains the value to locked binaries. Note that the key will
be available as long as the FileInUse dialog is active and once you cancel the
dialog the registry value will get cleaned up
In summary, based on your situation, you can use one of the above-mentioned tools or registry key to find out locked binaries
Comments
Post a Comment