MSI: Install Office Addin using vbs / COM
Hello,
I'm building an MSI which installs software that includes an Excel addin.
I was told that the proper way to do this is to create a custom action that runs a VB script that in turn add/removes the addin using COM.
I have these scripts ready and they also work when i run this as administrator on the client.
We're using SCCM to deploy the MSI and this installs the MSI in SYSTEM context. probably some things run with impersonation for the logged on user.
But the thing is that when i manually install this MSI as administrator, everything works. The addin get's added on install and removed on uninstall.
But when i deploy with SCCM, it does not work.
The MSI log shows that the custom action executes without error but the addin is not available for the logged-on user.
Do i need to change settings for the custom action? This is the config for the custom action in InstallShield:
This is the script for completeness (which works)
I hope someone can give me some tips!
Thanks!
I'm building an MSI which installs software that includes an Excel addin.
I was told that the proper way to do this is to create a custom action that runs a VB script that in turn add/removes the addin using COM.
I have these scripts ready and they also work when i run this as administrator on the client.
We're using SCCM to deploy the MSI and this installs the MSI in SYSTEM context. probably some things run with impersonation for the logged on user.
But the thing is that when i manually install this MSI as administrator, everything works. The addin get's added on install and removed on uninstall.
But when i deploy with SCCM, it does not work.
The MSI log shows that the custom action executes without error but the addin is not available for the logged-on user.
Do i need to change settings for the custom action? This is the config for the custom action in InstallShield:
This is the script for completeness (which works)
Option Explicit
Dim oXL, oFS, WSHShell, oFoldername, oAddin
Dim sProgramFilesFolder, sProgramFilesFolderx86
Dim sADDIN1
'On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")
sProgramFilesFolder = WSHShell.ExpandEnvironmentStrings("%ProgramFiles%")
sProgramFilesFolderx86 = WSHShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
If len(sProgramFilesFolderx86) > len("%ProgramFiles(x86)%") Then
sProgramFilesFolder = sProgramFilesFolderx86
End If
sADDIN1 = sProgramFilesFolder & "\Add-ins\addinmgr.xla"
set oXL = CreateObject("Excel.Application")
oXL.Workbooks.Add
If oFS.FileExists(sADDIN1) Then
set oAddin = oXL.Addins.Add(sADDIN1, True)
oAddin.Installed = True
End If
Set oAddin = Nothing
oXL.Quit
Set oXL = Nothing
I hope someone can give me some tips!
Thanks!
0 Comments
[ + ] Show comments
Answers (5)
Please log in to answer
Posted by:
anonymous_9363
13 years ago
First, there is an *awesome* script for dealing with Excel add-ins available as a "sticky" in the 'Scripting' forum. Use that: you'll be glad you did.
Second, to deploy the user-based part of the package you need to either use Active Setup (documented to death here on AD and elsewhere) or create a new feature as a parent of an existing feature which contains an advertised entry-point, so that when that entry-point is accessed, the Windows Installer engine will trigger self-healing (again, documented to death here) for that feature.
Second, to deploy the user-based part of the package you need to either use Active Setup (documented to death here on AD and elsewhere) or create a new feature as a parent of an existing feature which contains an advertised entry-point, so that when that entry-point is accessed, the Windows Installer engine will trigger self-healing (again, documented to death here) for that feature.
Posted by:
muijsenbergq
13 years ago
Ok,
I'm using the mentioned script now and it works great for the installation
I modified it a litte bit because i need to specify 1 single xla file (it's a suite of excel addins with 1 admin addin to manage the others)
Installation is successful. Installed as administrator and the addin also get's installed for the logged on user. This is what i want.
But now i also want the addin uninstalled when i run the uninstall.
The script does not uninstall the addin because the xla is not installed anymore at that stage:
this is what the scripts logs:
ExcelAddinStatus: Add-in 'C:\Program Files (x86)\Add-ins\addinmgr.xla' is not installed, so no removal necessary.
But the button is still there.
And if all the extra addins (which are managed by this addin) are also active, then there are loads of buttons left after uninstall.
What do i do about this?
The xla file obviously isn't there anymore because it's being removed by the MSI...
the code below works (a script i already had) when executed from outside of the MSI but when running as CA (deferred execution), the log says it ran but the addin is not removed for the logged-on user.
I run it after installInitialize.
Am i missing something?
thnx
I'm using the mentioned script now and it works great for the installation
I modified it a litte bit because i need to specify 1 single xla file (it's a suite of excel addins with 1 admin addin to manage the others)
Installation is successful. Installed as administrator and the addin also get's installed for the logged on user. This is what i want.
But now i also want the addin uninstalled when i run the uninstall.
The script does not uninstall the addin because the xla is not installed anymore at that stage:
this is what the scripts logs:
ExcelAddinStatus: Add-in 'C:\Program Files (x86)\Add-ins\addinmgr.xla' is not installed, so no removal necessary.
But the button is still there.
And if all the extra addins (which are managed by this addin) are also active, then there are loads of buttons left after uninstall.
What do i do about this?
The xla file obviously isn't there anymore because it's being removed by the MSI...
the code below works (a script i already had) when executed from outside of the MSI but when running as CA (deferred execution), the log says it ran but the addin is not removed for the logged-on user.
I run it after installInitialize.
Option Explicit
Dim oXL
Dim strCBarName
Dim i
' file name of addin to remove
Dim fileName : fileName = "Addinmgr.xla"
On Error Resume Next
Set oXL = CreateObject("Excel.Application")
oXL.Workbooks.Add
For i = 1 To oXL.AddIns.Count
If oXL.AddIns(i).Name = fileName Then
oXL.AddIns(i).Installed = False
End If
Next
oXL.Quit
Set oXL = Nothing
Am i missing something?
thnx
Posted by:
anonymous_9363
13 years ago
Posted by:
muijsenbergq
13 years ago
Neither,
The user gets the application advertised by SCCM, it gets installed (by SYSTEM) and after the setup the user has the addin available in excel.
This happens without active setup/entry point.
So this CA must be running in user context right?
Only removal of the addin doesn't work because the xla is not present at the time the CA runs.
I also get this behaviour when i run the MSI as administrator while user X is logged on and the start the app as user X. user X has the addin available after install but removal as administrator does not remove the addin for user X.
And i don't know why the script i posted to remove the addin doesn't work. The addin should run in user context right? The CA has the same settings (in installshield) as the CA to install the addin (which works using the script from the sticky)
Active setup is not an option because the user want to use his program immediately after setup and not have to log off first. How do i create an advertised entry point for a CA that needs to run in user context? Is this possible?
thnx
The user gets the application advertised by SCCM, it gets installed (by SYSTEM) and after the setup the user has the addin available in excel.
This happens without active setup/entry point.
So this CA must be running in user context right?
Only removal of the addin doesn't work because the xla is not present at the time the CA runs.
I also get this behaviour when i run the MSI as administrator while user X is logged on and the start the app as user X. user X has the addin available after install but removal as administrator does not remove the addin for user X.
And i don't know why the script i posted to remove the addin doesn't work. The addin should run in user context right? The CA has the same settings (in installshield) as the CA to install the addin (which works using the script from the sticky)
Active setup is not an option because the user want to use his program immediately after setup and not have to log off first. How do i create an advertised entry point for a CA that needs to run in user context? Is this possible?
thnx
Posted by:
anonymous_9363
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.