Last week I found out that one of our admin apps on the server was not installed currently. It is an app that is installed in ArcMap, and the reason it didn’t work is that ArcMap has been installed on
d:\programs files instead of
The msi depended on the location in
I opened the solution to try to fix the installer. I found that when you install ArcDesktop it adds an environment variable named
ARCGISHOME. I also found it is impossible to take a dll from a primary output in an msi and order the msi to put it in another folder.
So I used a custom action in the install phase with a VBScript file.
In order to do that you need to:
1. File –> New –> Text File
2. Save the text file with .vbs suffix under the setup project folder in the file system
3. Right click on the setup project is Visual Studio –> View –> Custom Actions
4. Right click on Install –> Add Custom Action
5. Select the vbs file and click OK.
Open the vbs file and write the following script:
Set wsShell = WScript.CreateObject("WScript.Shell") Dim targetDir = Session.Property("CustomActionData") RunScript = "xcopy """ + targetDir + "\somefiles"" ""%ARCGISHOME%bin""" wshell.run RunScript
In the vbs file properties under
Custom Action Data enter
[TARGETDIR]. This tells the msi to set the
CustomActionData property as the folder in which the msi deploys it’s main files.
Now, try to run this and surprise surprise... It doesn't work...
After of couple of frustrating debug trials, I found that when running VBScript in a MSI host, it can not used environment variables.
In order to use environment variables we can use the WScript method called ExpandEnvironmentStrings:
Set wsShell = WScript.CreateObject("WScript.Shell") Dim targetDir = Session.Property("CustomActionData") arcGisHomeDir = wsShell.ExpandEnvironmentStrings("%ARCGISHOME%") RunScript = "xcopy """ + targetDir + "\somefiles"" """ + arcGisHomeDir + "bin""" wshell.run RunScript
This one works perfectly.
Use it wisely.