Reputation: 1982
I have an Interop Excel application, installed via Window Installer, which contains only .dlls and no executables/.exes. It is seen by both "Add/Remove program" and wmic product get name
listing but not by the command 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
Upvotes: 2
Views: 8811
Reputation: 20780
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.
Upvotes: 4
Reputation: 55581
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.
Upvotes: 1
Reputation: 73576
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
Upvotes: 2