How to remove registry entries under HKCU?
HI,
I am working on an application called FSassist(Solvency) which is basically a xlsm file,which when clicked upon adds-in in Excel,when i unisntall this it leaves behing some registry entries under HKCU,(The unistal is clean for admin profile),
is there any way i can remove those entries during unistall?
any help would be really apprecited.
Thanks in advace.
Answers (6)
Remove HKCU key using ActiveSetup
If these machines are in a domain create a GPO that deletes these keys on login since the key set is not read till excell is started
Comments:
-
we ran into that when we uninstalled novell groupwise from our admin stations. An annoying popup came up everytime you started excell till we nuked the add on keys via GPO - SMal.tmcc 12 years ago
Have you tried adding the Excel Add-in in HKLM than in HKCU in the same hive?
It can work for all users if set there.
Comments:
-
The problem is MS's idea of add-ons. They see them as a per user item vs a machine item so when programs install the add-on for you they create the keys under hkcu. - SMal.tmcc 12 years ago
HI giri,
Please find below the vb code that u may require to delete the HKCU keys.
Note:
1. The script is to be kept in a machine specific locations such as the AllusersAppdata folder (C:\ProgramData\).
2. The script can either be added using file table (need to mark that component permanent) or using the binary table.
3. This script is to be called using active setup as specified by other members here. Its the most safest and easiest method available.
4. Replace strValueDataSearch = <FILENAME.XLA> in the below code with the xla addin file name
5. This code also checks for different Excel versions installed so as to check in the correct registry hive ;)
Option Explicit
On error resume next
Const IDOK = 1
Const IDCANCEL = 2
Const IDABORT = 3
Const IDRETRY = 4
Const IDIGNORE = 5
Const HKCU = &H80000001
Dim strComputer, objRegistry, strBaseKey, strSearch, strValueNameSearch, strValueDataSearch,objFSO, Os_Ver, objOS, intPrgPID, flag, Arr
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
set objFSO= createobject("scripting.filesystemobject")
Main
Function Main()
Call RemoveAddins1()
Main = IDOK
End Function
Function RemoveAddins1()
Dim arrValueNames, b, y, objExcel, objAddin, strValueData, a, x, strvalName, strOpen, intcount,strProgFiles,strExcel,objshell, strVer
intcount = 0
b=0
On Error Resume Next
Set objshell = Createobject("wscript.shell")
strExcel = "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Application\CurVer\"
strVer = objShell.RegRead(strEXcel)
If Instr(strVer,"11" ) Then
strBaseKey = "Software\Microsoft\Office\11.0\Excel\Options"
Elseif Instr(strVer,"12" ) Then
strBaseKey = "Software\Microsoft\Office\12.0\Excel\Options"
Elseif Instr(strVer,"14" ) Then
strBaseKey = "Software\Microsoft\Office\14.0\Excel\Options"
End If
strValueNameSearch = "open" 'Name of value to search for
strValueDataSearch = "<ADDIN FILENAME.XLA>" 'Value data search string - should always be in lower case
objRegistry.EnumValues HKCU, strBaseKey, arrValueNames
If Not IsNull(arrValueNames) Then
For y = 0 To UBound(arrValueNames)
If UBound(arrValueNames) > 1 Then
If InStr(LCase(Left(arrValueNames(y),4)), LCase(strValueNameSearch)) > 0 Then 'Get Values names
intcount=intcount + 1
objRegistry.GetStringValue HKCU, strBaseKey, arrValueNames(y), strValueData 'Get value data
strValueData = Mid(strValueData, 2,Len(strValueData)-2) 'Remove double quotesmsgbox strvaluedata
If InStr(LCase(strValueData), LCase(strValueDataSearch)) > 0 Then
objRegistry.DeleteValue HKCU, strBaseKey,arrValueNames(y)
For x = 0 To UBound(arrValueNames)
If InStr(LCase(Left(arrValueNames(x),4)), LCase(strValueNameSearch)) > 0 Then 'Get Values names
b = b + 1
If b = intcount+1 Then
objRegistry.GetStringValue HKCU, strBaseKey, arrValueNames(x), strValueData 'Get value data
strOpen= arrValueNames(x)
If b-2 = 0 Then
strvalName = Left (strOpen,4)
Else
strvalName = Left (strOpen,4) & CStr (b-2)
End If
objRegistry.SetStringValue HKCU, strBaseKey,strvalName, strValueData
objRegistry.DeleteValue HKCU, strBaseKey,arrValueNames(x)
intcount=intcount + 1
End If
End If
Next
End If
End If
Else
If InStr(LCase(Left(arrValueNames(y),4)), LCase(strValueNameSearch)) > 0 Then 'Get Values names
objRegistry.GetStringValue HKCU, strBaseKey, arrValueNames(y), strValueData 'Get value data
strValueData = Mid(strValueData, 2,Len(strValueData)-2) 'Remove double quotesmsgbox strvaluedata
If InStr(LCase(strValueData), LCase(strValueDataSearch)) > 0 Then
objRegistry.DeleteValue HKCU, strBaseKey,arrValueNames(y)
End If
End If
End If
Next
End If
End Function
Comments:
-
What happens if someone double click this .vbs file in production environment before uninstallation of this package..
Do not deliver this file during installation, Instead you can deliver it during uninstallation.. - jagadeish 12 years ago -
Or else you have to call this vbscript with some parameters... so that when someone double click this .vbs it will not remove the excel addin.. - jagadeish 12 years ago
You have to remove those HKCU key using ActiveSetup
Comments:
-
Is this what you were referring to?
http://www.itninja.com/blog/view/appdeploy-articles-activesetup - SMal.tmcc 12 years ago -
Yes.. Removing HKCU entries can not be done at the time of uninstallation itelf.. It has to be removed from all the user's HKCU registries..
At the time of uninstallation, You have to create a Active Setup.. and deliver a VBScript which will remove HKCU registry keys for currently logged in user to any common location like C:\Windows...
Your Active Setup should call your VBScript...
This VBScript will remove the HKCU keys for every users on their next logon - jagadeish 12 years ago -
Thanks, was trying to give some detail to your answer and did not want to miss-inform. - SMal.tmcc 12 years ago
-
Thanks SMal.tmcc - jagadeish 12 years ago
You can make it easy on yourself and leave the keys behind - any harm in that? Most of the time there’s nothing wrong with leaving old keys or old files after an uninstall has occurred. They don’t affect the system without the app that uses them.
If you must remove them, you're in for a small challenge. First you need to import the keys into the primary MSI so they already exist when the XLSM kicks on. Next, you’ll have to add two Active Setups – one for the install and one for the uninstall. For the install A.S, it’s the regular StubPath"="Msiexec.exe /fpu [ProductCode]" but for the uninstall, you’ll have to add an A.S. using SMal.tmcc’s suggestion of REG DELETE with a condition to be run only on uninstall.
Comments:
-
You can not leave Excel Addin's HKCU registry keys on uninstall... otherwise it will prompt a warning message and irritate you whenever you launch excel after uninstall - jagadeish 12 years ago
-
we ran into that when we uninstalled novell groupwise from our admin stations. An annoying popup came up everytime you started excell till we nuked the add on keys - SMal.tmcc 12 years ago