PDA

View Full Version : Renaming and Program Files folder...



installarama
11-07-2011, 04:32 PM
During install, we have to rename 64 *or* 32 bit compatible DLLs (depending on Win archtecture) and those files get installed in the "Program Files" folder.

The tough part is, the user may not have sufficient rights to allow renaming files in the "Program Files" folder itself.

So we are interested in ideas that will allow us to rename files during install *before* they arrive in the Program Files folder ...and we are thinking that some sort of trick or workaround or "pre-install" step might be needed.

We have tried things like simple InstallShield script as follows, but insufficient rights will be a problem:

function MyFunction(hMSI)
begin
if (SYSINFO.bIsWow64) then
RenameFile(INSTALLDIR+"\\64_name.dll",INSTALLDIR+"\\generic_name.dll");
endif;
end;

We'd appreciate any recommendations for how to rename files that belong in a potentially read-only folder...

Thanks!

TsungH
11-07-2011, 08:35 PM
I would recommend having the same filename for both 32- and 64-bit binaries, and installing the components conditionally based on the OS platform.

installarama
11-08-2011, 10:37 AM
TsungH and others:
We are not familiar with the techniques to do this...could you say a little more?

skolte
11-08-2011, 12:23 PM
I have used a C# custom action to rename the files. Basically you need to write a C# class with just one method that renames the files. Compile this class as a managed DLL and add that as a custom action to your installer project. In my case, the files are predefined and C# code determines the architecture so no need to pass anything from the installer. In case, you need to pass info to the C# custom action, you can always set the MSI Properties and read them in your custom action class.

The second approach much easier now, is the way 'TsungH' suggested. You create two components, one with 64bit assemblies, the other with 32bit assemblies. Select the 64bit Component, go to properties and you can simply set '64-Bit Component' property to Yes. You can use 'SYSINFO.bIsWow64 = 0' condition on 32 bit to ensure it install only when architecture is not 64bit.
I am not sure if you have already looked at this thread (http://kb.flexerasoftware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=http--communityflexerasoftwarecom-archive-indexphpt-162497html&sliceId=&docTypeID=DT_MACROVISIONCOMMUNITY_1_1&dialogID=118738960&stateId=0%200%20118734728).

TsungH
11-08-2011, 06:15 PM
To elaborate further, create 2 sets of components, 1 set for 32-bit, the other for 64-bit. It should follow best practice to have 1 file (exe, ocx, dll, chm or hlp) per component.

Set condition in Coponent Settings (http://documentation.installshield.com/Robo/BIN/Robo.dll?tpc=/robo/projects/installshield18helplib/ComponentSettings.htm) to install component conditionally. You will find a list of built-in Windows Installer properties here (http://msdn.microsoft.com/en-us/library/aa370905(VS.85).aspx).