cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gcggcg
Level 4

Rename a Folder

This should be simple and probably is. But I've spent all day with nothing but failure, hopefully someone can set me straight.

I need to be able to install the same set of files to a different location depending on the OS that's running on the target machine and whether it's the 32 bit or 64 bit version of the app that's being installed. For example, if installing a 32 bit version of the app on 64 bit windows then the files need to be placed in [CommonAppDataFolder]MyData (x86)\Config. If installing the 64 bit version of the app on 64 bit windows then the files need to be placed in [CommonAppDataFolder]MyData\Config.

The approach I've been pursuing is to create the MyData and Config folders under [CommonAppDataFolder] and then place all the installable files in these folders (they come from a huge number of components). Then I tried to use a "Set Directory" custom action to rename the MyData folder to MyData (x86) when I detected that I was installing the 32 bit version of the app on 64 bit Windows.

This seemed straight forward but I've had no luck. I've gotten a combination of errors depending on when I scheduled the execution of the CA and absolutely nothing has worked. I'm executing the CA "only once" but have included it in both the UI sequence and the Exec sequence. I've sequenced it "after CostFinalize" in both cases.

Further, I'm now at a point where I can't even uninstall it as I'm getting an "error 2343: Specified path is empty" message.

Can anyone help me with understanding a simple way to perform this simple function - basically renaming a folder.

Thanks!
Labels (1)
0 Kudos
(4) Replies
weakness
Level 6

Hello. gcggcg.

Sorry for if you already knew this...

First of all, do you know you can not create MSI package which supports both x86 and x64 environment?

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

For this reason, you may have to redesign your installer.
0 Kudos
enanrum
Level 9

UG - forget about the Custom Actions and renaming a Directory - gets tricky.

Just create 2 different components with the same files with different Install locations and use a condition on the component:

Destination = [CommonAppDataFolder]MyData (x86)\Config.
Condition = NOT VersionNT64

Destination = [CommonAppDataFolder]MyData\Config.
Condition = VersionNT64
0 Kudos
gcggcg
Level 4

Hi enanrum,

Thanks for the reply! I was able to find a way to do it with Custom Actions and, yes, it was tricky. This is a huge installer (9000+ files, 600 components, etc.). I had actually thought about your suggestion early on as a very good way to do it but it turns out that the number of files and components involved were just too many to make it practical.

Here's what ended up working for me:
- Create a folder named MyData in [CommonAppDataFolder]
- Create the Config folder in MyData
- Look at the directory table and get the identifier for the MyData folder(make it all uppercase if it isn't already)
- Create a public property that has the same name as this directory identifier
- Make sure that the value of this public property is null (delete the value)
- Create a "Set Property" custom action that references the public property
- In that custom action create a condition that is true when installing the 32 bit version of the product on 64 bit Windows (ISReleaseFlags><"32BitVersion" And VersionNT64)
- When this condition is true set the value of the property to [CommonAppDataFolder]MyData (x86)
- I ran this in both the UI Sequence and the Execute sequence and set it to "Execute only once".

This worked but, as you said, it is tricky, undocumented and a PITA for something so simple as renaming a directory at run time. It's not that it's all that difficult once you figure out what to do, it's that, to my knowledge, it's not documented anywhere so you're left to just wonder and experiment until you stumble upon something that works. You'd think InstallShield would have a built in CA for something like this or at least document it clearly somewhere.
0 Kudos
enanrum
Level 9

Good info. For those interested, this is also how you would install a component to a requested destination from a Custom Dialog, ie; I had to copy some files to a Siebel Server.

Another way rather than looking at the Directory Table is:
- "Application Data"->"Files and Folders"
- R-Click "Destination Computer" -> "Show Predefined Folders" and select the [CommonAppDataFolder] (CADF)
- R-Click CADF and Add your folder name under it - MyData
- R-Click on new folder and get the Directory Identifier - you can also rename it here to something more descriptive.

For the component that you want to change - use this Identifier for the Destination of the Component.

Setup the Set Property Custom Action. You can also run this CA in the Next Button of a Custom Dialog.
0 Kudos