/build/static/layout/Breadcrumb_cap_w.png

Add registry key on msi uninstall

Hey guys, im making an msi and I have tested it and it works fine. The thing is the msi is a temporary app for someting and will not be deployed for a long period of time. When I decide to uninstall the msi I would like to write a single registy key back to the machine. I use Installer Design Studio to make and edit all of my msi's and I've just been toying with the custom actions in there. Ive actually written a short vbs script to add the key back because it appears that the custom action has to be scripted in vbs or jscript (or an executable). For the custom action settings I have the options of:

Custom type-
VBScript stored in custom action table *have tested this*
VBScript stored in binary table *have tested this*
VBScript installed with product
VBScript on target machine

Execution Options-
Deferred Execution User Context
Rollback Execution User Context *have tested this*
Deferred Execution System Context
Rollback Execution System Context *have tested this*

Here is the VBS-
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKEY_USERS\.DEFAULT\Control Panel\Desktop\SCRNSAVE.EXE", "logon.scr", "REG_SZ"

After playing with verious combinations of the custom action and installing the msi manually and then uninstalling it again I cannot seem to get the regkey written back to the machine.

Does anyone have any ideas?
And yes, it is a Christmas screensaver ;)

0 Comments   [ + ] Show comments

Answers (11)

Posted by: anonymous_9363 17 years ago
Red Belt
0
Remove the 'WScript' directive. You cannot use it in CAs because 'WScript' refers to the Windows Scripting Host engine in Windows. Windows Installer/MSI uses its own internal engine:

Set WshShell = CreateObject("WScript.Shell")
Posted by: James 17 years ago
Senior Yellow Belt
0
Thanks for the quick reply VBScab!

So - I've created a custom action called setoldscreensaver, type = VBScript stored in custom action table, execution = Rollback Execution User Context. I've then added the following two lines:

Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite "HKEY_USERS\.DEFAULT\Control Panel\Desktop\SCRNSAVE.EXE", "logon.scr", "REG_SZ"

I Installed the msi manually, then uninstalled the msi and it still didnt create the regkey! :'(
Im obviously still doing something wrong, any further suggestions? Also- am I right in assuming that when i make the msi and deploy it via GPO then i should be using the execution option of 'Rollback Execution System Context' because the system will be uninstalling the msi and not the user?

James
Posted by: anonymous_9363 17 years ago
Red Belt
0
Rollback isn't the same as uninstall. Set a condition on the CA of IF REMOVE~="ALL"
Posted by: James 17 years ago
Senior Yellow Belt
0
Hey VBScab, im not sure I can set the condition of the custom action to anything other than those I listed in my first post as execution options. Ive looked through all of the custom action settings and cant find an option to manually set a condition for it. Ive included a screen shot IDS so you can see what I mean. Perhaps I sould be using another tool for the custom action?

Posted by: anonymous_9363 17 years ago
Red Belt
0
OK, you need to do some more reading, in particular on "conditions". I'm not familiar with the authoring tool you're using (Installer Design Studio) but I'm sure it will have installed a copy of MSI.CHM. If not, you can download the Installer SDK which will contain it. Again, as I don't know this tool, I'll advise on how to proceed with Orca (another part of the SDK and something you should already know about, at the very least). I'm sure the tool must have direct access to the tables, the same as Orca does. Anyway:

- Open your MSI in Orca
- Save a backup copy somewhere as a fall-back
- Browse to the InstallExecuteSequence table
- Find your Custom Action
- In the 'Condition' column, add the text
IF REMOVE~="ALL"
- Save the MSI.
- Test
Posted by: James 17 years ago
Senior Yellow Belt
0
VBScab, you've been most helpful and I very grateful for your time. The app im using (IDS) does indeed have access to the tables in a very similar fashion to Orca- again which I am very familiar with. I was not aware of msi.chm (im embaressed to say) but it looks very detailed. All knowledge of msi's that I have has come through testing and practice. I have created the custom action like you said and I did already look in the InstallExecuteSequence table before you mentioned it but the custom action does not appear there. I have manually tried adding the name of the customaction to the InstallExecuteSequence table but I got an error. The custom action is detailed in table form as follows:

Action= setoldsaver
Type = 38
Source = <empty/null>
Target= the vbs code I wish to run

msi.chm lists Type Value 38 as being 'msidbCustomActionTypeVBScript' which I assume is correct since I wish to run vbs. Im just a little baffed as to how to get InstallExecuteSequence to reference the customaction ive added, then I can set the condition you gave me and it should run.
Posted by: anonymous_9363 17 years ago
Red Belt
0
I did already look in the InstallExecuteSequence table before you mentioned it but the custom action does not appear there. It must be in the other sequence table, InstallUISequence, then. You'll need to move it from there into the correct table.
Posted by: James 17 years ago
Senior Yellow Belt
0
VBScab, ive tried looking in the InstallUISequence table, its not there either. The only place I can actually see it in all of the tables if in the CustomAction table. :-(
Posted by: anonymous_9363 17 years ago
Red Belt
0
Can you ZIP the MSI and post it here for me to look at?
Posted by: Coriolus 17 years ago
Orange Belt
0
ORIGINAL: VBScab

OK, you need to do some more reading, in particular on "conditions". I'm not familiar with the authoring tool you're using (Installer Design Studio) but I'm sure it will have installed a copy of MSI.CHM. If not, you can download the Installer SDK which will contain it. Again, as I don't know this tool, I'll advise on how to proceed with Orca (another part of the SDK and something you should already know about, at the very least). I'm sure the tool must have direct access to the tables, the same as Orca does. Anyway:

- Open your MSI in Orca
- Save a backup copy somewhere as a fall-back
- Browse to the InstallExecuteSequence table
- Find your Custom Action
- In the 'Condition' column, add the text
IF REMOVE~="ALL"
- Save the MSI.
- Test



Yes what he said, the Remove= ALL condition will perform this on uninstall

Check out this page:

http://www.installshield.com/news/newsletter/0212-articles/msiconditions.asp
Posted by: James 17 years ago
Senior Yellow Belt
0
Thanks VB Scab, its here:

http://hydrogen.chfs.org.uk/msi/
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