Page 1 of 1

Write Registry

Posted: Thu Aug 10, 2006 7:26 am
by paulga
Hi,

During installation I need to be able to check to see if a certain registry value under a key exists 'thevalue' , if it doesn't I will create it, if it does I will create another value 'thevaluetokeep' and give it the data copied from 'thevalue', I will then put new data in 'thevalue', this all works fine.

However I want to reverse this process on an uninstall to put things back as they were. I have tried to do a Write Registry under the Perform Uninstallation region after the Apply Uninstall command which doesn't seem to work.

Is it possible to write to the registry from this region? As I know the syntax is correct.

Thanks

Paul

Posted: Thu Aug 10, 2006 8:04 am
by Gizm0
You have to put it BEFORE the Apply Uninstall command.
Then it will work fine..

Posted: Thu Aug 10, 2006 9:21 am
by paulga
thanks for the reply,

I tried moving it before Apply uninstall but it still won't write to the registry. I can delete a value from the same point but not write a value.

Posted: Thu Aug 10, 2006 4:17 pm
by Gizm0
Can you post your script here?

Posted: Fri Aug 11, 2006 3:17 am
by paulga
Hi,

here is some of the script which I've tried to prune down:

[DEFINE REGION: Perform Uninstallation]
Comment: Uninstall product
Comment: TO-DO: Insert any additional uninstall commands here

Set Variable checkoldxvalue to
Check Registry Key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\oldx into checkoldxvalue

if Variable checkoldxvalue not Equals NO$VALUE
Comment: Value detected, better get it
Set Variable oldxval to

Read Registry Key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\oldx into oldxval

Write Registry Key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\val, $oldxkval$ (permanent)

Comment: now delete oldx
Delete Registry VALUE HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\oldx
end


Apply Uninstall (get result into variable SUCCESS)

Set Variable PROGRESS to 100


else
<<Code Folding Region>>


I have stepped through the code and it appears to be doing the correct things but without the results.

Posted: Fri Aug 11, 2006 5:46 am
by MichaelNesmith
Please read the help file section titled "Setup Commands Preceding Apply Uninstall". This answers your exact question.

Posted: Fri Aug 11, 2006 6:28 am
by paulga
I've just read that and that was one of the reasons I originally placed commands after the Apply Uninstall command. Does this explain why things that I try and write to the registry never appear?

Posted: Fri Aug 11, 2006 4:31 pm
by MichaelNesmith
If you want to write to the registry, you will need to do so before the Apply Install command, and make sure Apply Install executes. And any time your setup is being uninstalled, i.e. when Apply Uninstall is called, these changes will be removed.

I'm afraid there isn't a way to restore the former registry keys at uninstall time within the confines of Windows Installer. What you can do is use the Call DLL Function command to call a pre-existing DLL you may already have, which would restore those keys. You could call Run Program if you have an EXE that would restore these keys. Alternately, you could write an InstallAware plug-in to save and restore those keys. Whichever way you find easiest...

Posted: Mon Aug 14, 2006 2:18 am
by paulga
ok thanks Michael.