Excel Addin removal from all the users profiles
Thanks
Answers (17)
Thanks DJ, I have to handle office xp and office 2003. I have a script that reads the registry into temporary file and searches for the particulat xll or xla file, i wanted to remove it from all users so that when another user logs into the machine and launches excel after the addin removal he does not get an error message .
"XYZ" installs excel add-ins and in user profile hence the addins are not installed to Excel if a different user logs onto the machine.
Any idea what's the best way of doing this?
Cheers,
Vivek
The error will pop up if you don't remove the entry in the HKCU registry. Anyway, here is my script. Feel free to modify it and send me... feedbacks...[:D]
**************************************
'DJ Xest
'Description: Used to remove Excel Add-Ins automatically in Office XP and Office 2003. Limited up to 100 Add-Ins only.
On Error Resume Next
Dim SCA,SCA1,XLReg,XLReg1,a,b
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
SCA="""" & "{Path and name of .xla}" & """"
SCA1="""" & "{Path and name of .xla}" & """"
XLReg=WshShell.RegRead ("HKCU\Software\Microsoft\Office\10.0\Excel\Options\OPEN")
XLReg1=WshShell.RegRead ("HKCU\Software\Microsoft\Office\11.0\Excel\Options\OPEN")
comparevalue=strcomp(XLReg, SCA, 1)
comparevalue1=strcomp(XLReg1, SCA1, 1)
if comparevalue=0 Then
WshShell.Regdelete ("HKCU\Software\Microsoft\Office\10.0\Excel\Options\OPEN")
end if
if comparevalue1=0 Then
WshShell.Regdelete ("HKCU\Software\Microsoft\Office\11.0\Excel\Options\OPEN")
end if
For a = 1 to 99
XLReg=WshShell.RegRead ("HKCU\Software\Microsoft\Office\10.0\Excel\Options\OPEN" & a)
if XLReg=SCA then
WshShell.Regdelete ("HKCU\Software\Microsoft\Office\10.0\Excel\Options\OPEN" & a)
exit for
end if
Next
For b = 1 to 99
XLReg1=WshShell.RegRead ("HKCU\Software\Microsoft\Office\11.0\Excel\Options\OPEN" & b)
if XLReg1=SCA1 then
WshShell.Regdelete ("HKCU\Software\Microsoft\Office\11.0\Excel\Options\OPEN" & b)
exit for
end if
Next
Wscript.Quit
**********************************
I have used a script from ©
Bill Jamesand made some changes to it to search for the exact file name and output as a reg file, not many changes are made except to make it silent, credit goes to Bill James.
Needs some more modifications on how to remove it from all the profiles and to change then rearrange the OPEN key values
****************************************************************************************************************
****************************************************************************************************************
Option Explicit
Dim oWS : Set oWS = CreateObject("WScript.Shell")
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim sSearchFor
' Change here for the addin to get removed add the exact entry as in the registry
sSearchFor = "/R \" &chr(34) &"C:\\Program Files\\Microsoft Office\\OFFICE11\\Library\\Analysis\\ANALYS32.XLL\" &chr(34)
'sSearchFor = "/R \" &chr(34) &"C:\\Essbase\\bin\\essexcln.xll\" &chr(34)
'sSearchFor = chr(34) &"\" &chr(34) &"C:\\Essbase\\bin\\essxleqd.xla\" &chr(34)
'MsgBox (sSearchFor)
If sSearchFor = "" Then Cleanup()
Dim StartTime : StartTime = Timer
Dim sRegTmp, sOutTmp, eRegLine, iCnt, sRegKey, aRegFileLines
sRegTmp = oWS.Environment("Process")("Temp") & "\RegTmp.tmp "
sOutTmp = oWS.Environment("Process")("Temp") & "\sOutTmp" & _
Hour(Now) & Minute(Now) & Second(Now) & ".tmp "
oWS.Run "regedit /e /a " & sRegTmp, , True '/a enables export as Ansi for WinXP
With oFSO.OpenTextFile(sOutTmp, 8, True)
.WriteLine("Windows Registry Editor Version 5.00" & VbCrLf)
With oFSO.GetFile(sRegTmp)
aRegFileLines = Split(.OpenAsTextStream(1, 0).Read(.Size), vbcrlf)
End With
oFSO.DeleteFile(sRegTmp)
For Each eRegLine in aRegFileLines
If InStr(1, eRegLine, "[", 1) > 0 Then sRegKey = eRegLine
If InStr(1, eRegLine, sSearchFor, 1) > 0 Then
If sRegKey <> eRegLine Then
If InStr(sRegKey,"11.0") then
.WriteLine(VbCrLf &"[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Options]") & vbcrlf & "-" &eRegLine
Else
.WriteLine(VbCrLf &"[HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Options]") & vbcrlf & "-" &eRegLine
End If
Else
.WriteLine(vbcrlf & sRegKey)
End If
iCnt = iCnt + 1
End If
Next
Erase aRegFileLines
If iCnt < 1 Then
.Close
oFSO.DeleteFile(sOutTmp)
Cleanup()
End If
.Close
End With
if oFSO.FileExists ("C:\TEMP\HKCU_ExcelAddin.reg") Then
oFSO.DeleteFile("C:\TEMP\HKCU_ExcelAddin.reg")
else
oFSO.CreateTextFile("C:\TEMP\HKCU_ExcelAddin.reg")
oFSO.CopyFile sOutTmp, "C:\TEMP\HKCU_ExcelAddin.reg"
oFSO.DeleteFile(sOutTmp)
End if
'Dim oApp
' Set oApp = CreateObject("Excel.Application")
' oApp.Application.Visible = True
' oApp.AddIns("Analysis ToolPak").Installed = False
' oApp.Application.Quit
' set oApp = Nothing
Cleanup()
Sub Cleanup()
Set oWS = Nothing
Set oFSO = Nothing
WScript.Quit
End Sub
Do you think you can put your script that will launch on startup for all users? Let's say put it in registry
(i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run) or startup folder so that when other users login excel-addin will be removed for them? What do you think? BTW, I can't make your script works on my end. Can you check?
As far as my understanding goes...
The only way to remove the addin keys from all users whoever logs in to the machine is either by
Using a runkey to run your vbscript as DJ suggested (or)
Use an activesetup routine (which should be implemented) on removal of the application.
The only difference being Runkey being run for each login of any user where as activesetup being run once per user login.
Hope this makes sense guys..
And correct me if i had been wrong.. [:D]
what the script does it, it searches the entire registry for the excel addin name as is in the registry and converts it into a regkey with a '-' appended to the regvalue,
we have a inhouse tool that uses this registry key and removes it from alll the user registry profile under HKEY_USERS.
DJ check the temp directory for the reg file, and make sure the Value you are searching is exactly the same as in the registry .
On Error Resume Next
Dim oXL : Set oXL = CreateObject("Excel.Application")
Dim oAddin : Set oAddin = oXL.AddIns.Add(session.property("INSTALLDIR") & "ist.xla", True)
oXL.Workbooks.Add
oAddin.Installed = True
oXL.Quit
Set oAddin = Nothing
Set oXL = Nothing
‘*************************************************************************
'Under Install Execute Sequence
'Location: AFTER InstallFinalize
'Condition: NOT REMOVE
'Properties: Immediate Execution; Synchronous; Always Execute
Here is the code for removing and add-in;
On Error Resume Next
Dim oXL : Set oXL = CreateObject("Excel.Application")
Dim oAddin : Set oAddin = oXL.AddIns.Add(session.property("INSTALLDIR") & "ist.xla", False)
oXL.Workbooks.Add
oAddin.Installed = False
oXL.Quit
Set oAddin = Nothing
Set oXL = Nothing
‘******************************************************************
'Under Install Execute Sequence
'Location : AFTER InstallInitialize
'Condition: REMOVE
'Properties: Immediate Execution; Synchronous; Always Execute
‘*************************************************************************
The above code may be altered to either run as an embedded vbscript from within a msi or in the case of multi user or Admin –vs- User installations the scripts can be best triggered via Microsoft Active Setup.
Last week, I did some work in the registry to try and have my Excel Add-In automatically added to every user on our Terminal Server box when they log on.
I went under the following registry address and added a new string value OPENx to reference the path of my .xla file:
HKEY_CURRENT_USER\Software\Mcirosoft\Office\xx.x\Excel\Options
I'm not sure if I also did something simliar under the HKEY_LOCAL_MACHINE path to add a simliar string value, but now every user that logs on to that Terminal Server and opens their Excel program, the add-in is automatically there.
Further, I deleted the string values. The Admin user's version of Excel had its add-in removed, but strangely, all other users can still access the add-in when logged in under that Terminal Server. This is baffling me.
As well, I tried to implement the same steps on our second Terminal Server box, but this time it's not working.
I tried to add the OPENx string value in each of the following registry paths but nothing happened:
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
I guess I'm trying to find an answer to how it worked on our first Terminal Server. The ideal solution was to add the add-in via the registry so that users don't have to add it themselves. Miraculously it worked last week, but this week as I tried to do the same thing on our second box, it didn't work.
Anyone know how properly add an add-in in the registry so that it's automatically installed on every users' Excel program? As well, to remove the add-in so that it becomes unavailable?
It's strange that after I removed the string values that are referencing the .xla file, all users are still able to access the add-in.
If anyone can offer guidance on this matter, I would really appreciate it.
Regards.
This avoid to scrap other Addin excel (Work for all users) (Can be used in a custom action - Installshield)
On Error Resume Next
Dim WshShell
Set WshShell = WScript.CreateObject("Wscript.Shell")
Dim Addin, Open
Dim Count : Count = 0
Dim Found : Found = 0
Addin = """C:\Program Files\ComanyName\SoftwareName\Sofware.xlam"""
Open = WshShell.RegRead("HKCU\Software\Microsoft\Office\"OfficeVersion"\Excel\options\OPEN")
If IsEmpty(Open) Then
WshShell.RegWrite "HKCU\Software\Microsoft\Office\"OfficeVersion"\Excel\options\OPEN", Addin
Else
Do While Not IsEmpty(Open)
If UCase(Open) = UCase(Addin) Then
Found = 1
Exit Do
End If
Count = Count + 1
Open = Empty
Open = WshShell.RegRead("HKCU\Software\Microsoft\Office\"OfficeVersion"\Excel\options\OPEN" & CStr(Count))
Loop
If Found = 0 Then WshShell.RegWrite "HKCU\Software\Microsoft\Office\"OfficeVersion"\Excel\options\OPEN" & CStr(Count), Addin
End If
so that the conversation will remain readable.