Running VBScript on Uninstall - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

lekfir
Posts: 130
Joined: Sun Feb 15, 2009 5:26 pm

Running VBScript on Uninstall

Hi,
What is the best way to run a vbs file that clean up the registry on uninstall?
Any 'How-To' guide?

Thanks!
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Running VBScript on Uninstall

Hi,

For cleaning up the registry on uninstall AI has predefined features in the Registry page. The Registry Key Removal Dialog can be displayed by double clicking on the desired key from the registry tree.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lekfir
Posts: 130
Joined: Sun Feb 15, 2009 5:26 pm

Re: Running VBScript on Uninstall

Thanks.
But I need to delete specific value from a registry key.
It finds a specific string in a key and will delete only the string.

For example:
in HKEY_LOCAL_MACHINE\Software\Microsoft\Macromedia\FlashPlayer the value of the string Command is Goto, Leave, Test, Help
I want to check if the string 'Leave' exists and if the answer is Yes, then delete it so the new value will be Goto, Test, Help
The string 'Leave' might appear at the beginning , second, third or at the end of the value...

In addition, I would like that the file will be embedded in the MSI so it will run even if the user deleted the file from Program files...
Thanks!
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Running VBScript on Uninstall

Hi,

You can add the script as a New Attached Custom Action under the Uninstall phase, in the Custom Actions page.

This way the “Execution Condition” field will be set to:

Code: Select all

 REMOVE = “ALL” 
meaning that the custom action will run only during uninstall.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lekfir
Posts: 130
Joined: Sun Feb 15, 2009 5:26 pm

Re: Running VBScript on Uninstall

Thanks,
When I run the script locally on the PC it cleans the registry but when i run it from the MSI, it doesn't clean it.

I checked the uninstall log and the folowing error appear:

Info 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action CleanUp script error -2146827263, Microsoft VBScript compilation error: Expected end of statement Line 1, Column 20, CleanUp value

Here is my VBS code...

Set objShell = WScript.CreateObject("WScript.Shell")

Function RunReplace(patrn, replStr)
Dim regEx, strObj
Set regEx = New RegExp
strObj = objShell.RegRead _
("HKLM\SOFTWARE\...


Here are my AIP file settings:

Install Execute Sequence: -> Uninstall
Source Type: Visual Basic Script
Action :[#CleanUp.vbs]
Synchronous execution, ignore return code
Deffered with no impersonation
Always Execute
Execution Condition: REMOVE = “ALL”
Run when patch in uninstalled (Selected)
Last edited by lekfir on Mon Aug 10, 2009 1:11 pm, edited 1 time in total.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Running VBScript on Uninstall

Hi,

The “Action Data” field should be empty. Source Type field is set correctly. The path of the file should appear in the “Source Path“ field, you can fill it in using the “...” button.

Also in the Function Name field you can specify the name of a function that you call from your script. If there is no function defined this field should also be left empty.

I see you've checked “Run when patch is uninstalled(...)” checkbox. This makes the custom action run only when the PATCH which contains it is uninstalled. But you have a MSI package from what I understand. Could you please tell me why you selected this option?

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lekfir
Posts: 130
Joined: Sun Feb 15, 2009 5:26 pm

Re: Running VBScript on Uninstall

Thanks.
I edited my last replied post.
I got an error while uninstalling.

Please see screenshot of my Custom Action.
http://www.sendspace.com/file/0g7u2x

Some fields that you have mentioned don't exist. For Example, Source Type...
Thanks
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Running VBScript on Uninstall

Hi,

You can not find those fields because you've created a "Script Inline" custom action. To create an ATTACHED custom action as I said before follow these steps:
-- right click on Uninstall
-- select "New Attached Custom Action"
-- use the browse dialog that appears to find your .vbs file and select it
-- after you've done the above actions check the fields I have reminded in my previous post

This should solve your problem.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lekfir
Posts: 130
Joined: Sun Feb 15, 2009 5:26 pm

Re: Running VBScript on Uninstall

Bogdan,

Still I got the following error:
Info 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action CleanUp.vbs script error -2146827864, Microsoft VBScript runtime error: Object required: 'WScript' Line 1, Column 1,

While my VBSCRIPT started with:

Set objShell = WScript.CreateObject("WScript.Shell")
Function RunReplace(patrn, replStr)
Dim regEx, strObj
Set regEx = New RegExp
strObj = objShell.RegRead _
("HKLM\SOFTWARE\...


When I changed the first line to:
Set objShell = CreateObject("WScript.Shell")

As described here: http://social.msdn.microsoft.com/Forums ... 1c6e75e177
It worked!
Thanks a lot for your efforts!
Lekfir

Return to “Common Problems”