2

I have an Interop Excel application, installed via Window Installer, which contains only .dlls and not executables .exe. It is seen by both Add/Remove program and wmic product get name listing but not by command line where (refering to here)

I am writing a batch file to modify some files after installation. How can I get the installation path of this program in my batch file ?

I should also mention that although Add/Remove Program sees the program, it does not exist in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Community
  • 1
  • 1
Kenny
  • 1,422
  • 3
  • 23
  • 47

3 Answers3

4

It's my guess that you won't be able to find out because the install path is not automatically recorded in the uninstall registry info unless your setup set the ARPINSTALLLOCATION property:

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

or you explicitly created a registry item and set its value to [TARGETDIR] which is what you could do in future if you want to save the location somewhere under your control.

So Chris's answer is likely to be the correct method for finding a path, and also correct in telling you not to replace files. Installer resilience (or a repair from Add/Remove Programs or right-click on the MSI file-repair) is likely to restore them, requiring the original MSI. MSI knows the file versions of what was installed. In addition, an upgrade or a patch may also need the original MSI. Caveat Emptor.

PhilDW
  • 19,260
  • 1
  • 14
  • 23
2

Use WMIC's where to specify the name to look for and get InstallLocation to show the path:

for /f "delims=" %%a in ('
    wmic product where "Name='Exact name of your app'" get InstallLocation ^| find "\"
') do set location=%%a
wOxxOm
  • 43,497
  • 7
  • 75
  • 96
  • Thanks @wOxxOm for the response. Unfortunately InstallLocation returns nothing. I don't get it either as InstallSource, InstallState, Vendor, etc. do give good results. Pehaps this has something to do with the fact that it is en Interop Excel application ? – Kenny Nov 19 '15 at 11:33
  • Besides, I have the impression that wmic queries the installed program in _HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall_, in which I see that there are many that do not have InstallLocation either. – Kenny Nov 19 '15 at 11:42
  • Can I install this application to test? Otherwise I can only suggest searching the registry via `reg query`, there are many examples. – wOxxOm Nov 19 '15 at 12:00
  • Also `WMIC softwareelement get Path` ([available fields](https://msdn.microsoft.com/en-us/library/aa394453(v=vs.85).aspx)) or `softwarefeature` may be helpful. – wOxxOm Nov 19 '15 at 12:12
  • Try running `wmic softwareelement where "name like '%SOMETHING%'" get Name, Caption, Path` – wOxxOm Nov 19 '15 at 12:21
  • I am sorry since it's a product of my company so I could not risk. But I believe any Excel interop application will behave similarly. Besides you can have a look at the registry to see that there are other apps that has InstallLocation empty. – Kenny Nov 20 '15 at 11:31
  • @Kenny, I don't know any other such app (maybe you can name one). And what about those other commands in my comments, not interested? – wOxxOm Nov 20 '15 at 12:03
  • Yes your answer is certainly helpful. I find that it takes quite long to response and it does not find the software I query. If you 'd like to see some entries without InstallLocation, in my HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall there are many : Visual studio 2013 Prerequisite, Microsoft Visual C++ redistributable, etc. – Kenny Nov 23 '15 at 13:45
  • @Kenny, that product doesn't have any centralized InstallLocation, there are many dlls in different folders, **but** since you know the dll file name what about `reg query HKCR\Installer\Assemblies /k /f YourDLLname.dll.dll` - note the double dll extension which finds language-neutral entry (maybe you only need one `.dll` extension). – wOxxOm Nov 23 '15 at 13:57
1

The WMI provider for MSI has always been buggy. I'd use the native MSI API to ask it where the components are installed. (MsiGetComponentPathEx function)

But I have to advise that MSI likes to "own" it's files. If someone does a repair it's very likely that your modifications will be history. I'd advise transforming the MSI to contain the modified files and skip the post install modification step. Either that or redesign your addin so that you can have a base set of values installed by MSI and an override set of values copied outside of MSI that MSI doesn't know about.

Christopher Painter
  • 52,390
  • 6
  • 60
  • 97
  • Thanks Christ. I am using C# so slipping C++ code in would not be what my supervisor wants. Besides, as far as I understand, it queries from _HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\_, which as I mentioned in the discussion with wOxxOm, does not contain information on InstallLocation – Kenny Nov 23 '15 at 13:50
  • P/Invoking Win32 APIs from C# isn't slipping in C++ code. Also, the MSI API does not get it's information from the key you mention, it gets it from it's own datastore in HKCR\Software\Installer. That can be HKLM or HKCU depending on the dwContext that is provided to the function. – Christopher Painter Nov 23 '15 at 14:02