/build/static/layout/Breadcrumb_cap_w.png

installing reg keys on uninstall

hi guys,
i have a messy vendor msi that removes some keys on uninstall that breaks one of our in-house services that are on the build.
i have narrowed it down to HKCR keys but there are alot of them.
I want to install these on uninstall via my mst.
what is the best way to do this?
should i create a component add the keys and put the condition REMOVE~="ALL" on that component?
should i create a custom action to import the .reg file perhaps?
any feedback welcomed!

0 Comments   [ + ] Show comments

Answers (17)

Posted by: nheim 17 years ago
10th Degree Black Belt
0
Hi Mark,
you need to do it with a Custom Action. The 'WriteRegistryValues' action does not run on a uninstall.
Regards, Nick
Posted by: frodo 17 years ago
Orange Senior Belt
0
cheers nick,
is it possible to do this without installing the .reg file.
for example run the command line and query the binary table for the reg file?
I need to do my CA at the very end of uninstall . After a quick think i believe i will have to install the reg file and leave it as permanent so it does not get uninstalled by the remove files action.
i then need to run a CA that runs the command line regedit.exe /S MyKeys.reg.
how can i do this without installing the reg file to a location so that my Ca can use it?

thanks again for your help Nick.
Posted by: AngelD 17 years ago
Red Belt
0
Find the registry entries you don't want to be removed during uninstall and check which component(s) these are part of. Then make these component(s) permanent so they will not get removed during uninstall. To do this add the msidbComponentAttributesPermanent attribute bit to the Attributes column in the Component table for the components you found previous.
Posted by: JdotQ 17 years ago
Senior Purple Belt
0
ORIGINAL: frodo
should i create a component add the keys and put the condition REMOVE~="ALL" on that component?


Not sure if it's a typo, but figured I would mention it anyway...

With conditions, REMOVE = "ALL" will be executed during an uninstall sequence, REMOVE <> "ALL" will be executed during an install sequence (at least this syntax is true for AdminStudio, not sure about Wise but I think it would the same/similar)

(( Please correct me if I'm wrong [:D] ))
Posted by: AngelD 17 years ago
Red Belt
0
REMOVE~="ALL"
That is not a typo, the "~" character will make sure that the condition expression isn't case sensitive.
The condition will for example also resolve to true if REMOVE has the value of "All".
Posted by: frodo 17 years ago
Orange Senior Belt
0
ok guys,
just to be clear, i added the keys to a permanent component but no joy.
the vendor msi removes the keys via a custom action and i cant pinpoint which one.
my only option is to use a custom action to install the reg keys on uninstall.
with that in mind,
i have my .reg file and my command line to run it regedit /s mykeys.reg
is there anyway i can run it without installing the .reg file to the local machine?


i know i could create a vb custom action to create each key but i dont have the time to go through the .reg and add each key to the vb code!

help on this custom action creation is much appreciated.
Posted by: nheim 17 years ago
10th Degree Black Belt
0
Hi Mark,
i would do this with reg.exe not with regedit.
If you can be sure, this MSI will be only installed on XP, you can rely that reg.exe is on the clients.
Create a batch batch file with a reg entry for each line, you have to write and put it into the binary table.
Call it with a deferred CA right before InstallFinalize.
Hope, this gives you some ideas.
Regards, Nick
Posted by: frodo 17 years ago
Orange Senior Belt
0
as if it couldnt get any worse, its a Wins 2000 target...agghhhh.
thanks for the help Nick
Posted by: nheim 17 years ago
10th Degree Black Belt
0
Hi Mark,
thats far from worse, it's a challenge! :-)
do it with VB script then.
Search this forum, you get plenty of examples.
Put it into the binary table and call it deferred just before InstallFinalize.
Happy scripting.
Regards, Nick
Posted by: frodo 17 years ago
Orange Senior Belt
0
cheers Nick, you are sticking with me on this.
if i add my .reg file to the binary table how do i call it in the vbscript custom action?
i need to use it as an argument to pass to regedit.exe
Posted by: nheim 17 years ago
10th Degree Black Belt
0
Hi Mark,
you can't use a reg file for this. You have to work the reg keys into a VB script and put this into the binary table.
Regards, Nick
Posted by: AngelD 17 years ago
Red Belt
0
Nick,

Just of interest, why can't he use regedit to import a .reg file?

Anyway here is a vbscript that you could use as a custom action to extract the .reg file from the Binary table, run regedit to import the file and delete the exported .reg file. You have to add the code for execution of regedit yourself.

Make sure to change the BinaryName value to the PrimaryKey From the binary table for your .reg file.

Dim BinaryName : BinaryName = "PrimaryKeyFromBinaryTable"
Dim TempFile : TempFile = ReturnTempFile()

Call ExtractBinary(BinaryName, TempFile)
'// import .reg file using regedit
Call DeleteFile(TempFile)

Function ExtractBinary(BinaryName, OutputFile)
Const msiReadStreamAnsi = 2

Dim Database : Set Database = Session.Database

Dim View : Set View = Database.OpenView("SELECT * FROM Binary WHERE Name = '" & BinaryName & "'")
View.Execute
Dim Record : Set Record = View.Fetch
Dim BinaryData : BinaryData = Record.ReadStream(2, Record.DataSize(2), msiReadStreamAnsi)

Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Stream : Set Stream = FSO.CreateTextFile(OutputFile, True)
Stream.Write BinaryData
Stream.Close
End Function

Function ReturnTempFile()
Const TemporaryFolder = 2

Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim TempFolder : Set TempFolder = FSO.GetSpecialFolder(TemporaryFolder)
Dim Tempfile : Tempfile = FSO.GetTempName

ReturnTempFile = TempFolder.Path & "\" & Tempfile
End Function

Function DeleteFile(FilePath)
On Error Resume Next

Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFile(FilePath, True)
End Function
Posted by: nheim 17 years ago
10th Degree Black Belt
0
Hi AngelD,
you just proved me wrong with this one. Have used this method a few times too (although, not with registry files).
Just thought, it would complicate things more, than use a single VB script file. But this maybe depends on the size of the reg file.

@Mark,
Something like this: http://itninja.com/question/ghost-8.0-on-lan1&mpage=1&key=vbs%2Cregistry㉇
could do the job in a single VBS file.

Regards, Nick
Posted by: jmcfadyen 17 years ago
5th Degree Black Belt
0
i would try to avoid using the reg file as in some instances you can come to grief with GPO's that lockdown the access to the regedit.exe.

If you running unsecured it should be ok, but these days more often than not places seem to run tighter lockdowns.
Posted by: frodo 17 years ago
Orange Senior Belt
0
thx for all the help guys.
AngelID thx for your custom action code, it worked a treat, exactly what i wanted.
Posted by: spartacus 17 years ago
Black Belt
0
ORIGINAL: frodo
the vendor msi removes the keys via a custom action and i cant pinpoint which one.


No disrepect intended to previous replies but given the scale of the task you are facing it may be worth a bit more perseverence trying to track down the vendor's custom action responsible for the issue.

Presumably the vendor's custom action is conditioned such that it only runs on uninstall (?) If so, could you not locate all the custom actions so conditioned and disable them all.

Then reinstate them one-by-one doing uninstall tests at each stage until you see the registry keys/values being removed. Once you have found the CA responsible, you could then remove/disable it permanently.

I know it's likely to be a tedious task, but it could be worth the effort in the long run .. [;)]

Regards,

Spartacus
Posted by: AngelD 17 years ago
Red Belt
0
The CA would likely be executed after the WriteRegistryValues action which would minimize CAs you have to look/test for, but hey we know how vendors seems to do anything but correct.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ