congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Uninstall Cleanup for registry

Hi
By the default, the uninstaller only remove registry value which it added. So if I add an .exe file run as a custom action and it add some registry value in HKLM\SOFTWARE\YOUR COMPANY\xxx. If .exe run failt, the rollback will remove registry which it create before, but my custom registry value was not remove.So I choose Uninstall cleanup for HKLM\SOFTWARE\YOUR COMPANY but it still not working. U can tell me why? Thanks
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

Hi.
Maybe it is impossible to use uninstall cleanup for registry value which wasnot created by the installation process. So I found another way for my scenario. The install will search the existence of Boot.ini file and if exist boot.ini file, the install will add registry to HKLM\SOFTWARE\MY COMPANY\MY PRODUCT\BOOTINI
name: existence, type REG_SZ, data 1 (if exist) or 0 (if not exist).
Only by this way, the registry will be removed when I uninstall my product. But I don't know how to do it. If u can, please help me. Thanks
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,
Maybe it is impossible to use uninstall cleanup for registry value which wasnot created by the installation process.
It is possible to use the "Uninstall Cleanup" feature for registry entries that were not created by the installer, but this feature does not run during the rollback of the installation, it runs only during an uninstall.
The install will search the existence of Boot.ini file and if exist boot.ini file, the install will add registry to HKLM\SOFTWARE\MY COMPANY\MY PRODUCT\BOOTINI
name: existence, type REG_SZ, data 1 (if exist) or 0 (if not exist).
Only by this way, the registry will be removed when I uninstall my product. But I don't know how to do it. If u can, please help me. Thanks
In order to achieve this you can use the INI Search feature. Just go in the Search page, and use the [ Search ] button to add a new search ( you can rename that search i.e. REG_VALUE1). Right-click on that search and select the "Add Location -> INI file" option.

Then you can go in the Registry page, create your registry entry and use the search property as a value for your registry entry (i.e. [REG_VALUE1]). For many registry entries, create more INI searches and use them.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

Thank you for your reply, @Eusebiu.
I follow your guide and it work fine.
Now I have a problem. At File and Folder Page, I right click on boot.ini file, goto Operations Tab, choose Do not overwrite existing file, Condition: 1.But when I run the setup, boot.ini still replaced. I change it to 0, nothing's changed. So I add a search boot.ini file with property name: BOOT then choose "Do not overwrite existing file", Condition: BOOT. The problem still was not resolved. Finally I goto Organization Page, choose boot.ini at main feature, choose check box : never overwrite and my problem was resolved. So, I don't know the difference between them. Why the first and second way did not work properly?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,

Sorry, but it seems that I misunderstood your scenario.

In order to find if the "boot.ini" file exists, you can create a File Search and rename it (i.e. BOOT_FILE), then right click on that search and choose the "Add Location -> Folder" option. In the "Path" of the folder write the location of the file (i.e. [WindowsVolume]) and in the "Name" field of the created search, write the name of the file (i.e. boot.ini).

In the Install Parameters page create a new property (i.e. EXISTENCE) then, in the Registry page create the "existence" value that you want to add to the registry and in its value field write the [EXISTENCE] property.

Go in the Custom Actions page and add two "Set property" custom actions after the "Install Executions Stage -> Searches" action group and configure them as described below:
  • Property: EXISTENCE
    Value: 1
    Condition: BOOT_FILE

    Property: EXISTENCE
    Value: 0
    Condition: NOT BOOT_FILE
In this case the [EXISTENCE] property will be set to "1" if the "BOOT_FILE" search was true or to "0" if the search was false (the "boot.ini" file was not found).

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

I'm sorry. About adding registry base on the existence of boot.ini file, I followed your guide and I did it. Now I get some issue about "overwrite" a file which existed before.
I don't want to overwrite boot.ini file and to archive it, I take by 3 ways.
First way: At File and Folder Page, I right click then choose properties on boot.ini file, goto Operations Tab, choose "Do not overwrite existing file" (Condition: leave default, here is 1). Build and install, boot.ini was replaced. I change condition value to 0, but nothing's changed).

I tried second way. Goto Search Page, add a search Boot.ini file (PROPERTY NAME: BOOT), then goto File and Folder Page, I right click then choose properties on boot.ini file, goto Operations Tab, choose "Do not overwrite existing file" BUT at condition field, I choose BOOT. Build and install, boot.ini file still was replaced.

I tried third way. Goto Organazation Page, choose Boot.ini, at the right panel, I check "Never Overwrite box" then build and install and my issue was resolved.
So my question is: What differences between 3 ways that I did? And why the first way and the second way can't help me prevent the install overwrite boot.ini file?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,

I will explain the differences between the three methods below, however I'm not sure why the first two did not work, but they all should have worked.
1. The "Do not overwrite existing file" option is a custom action that is always executed when its condition is "1" and it is never executed if its condition is "0". This custom action makes a backup of your file before it is removed during the upgrade and restores it after the installation of the new version.
2. Same as above, only the condition was different.
3. The "Never Overwrite" option sets a flag for the component related to your file, so that during the upgrade, if the file is found on the machine it will not be overwritten by the file from the package.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

Hi
Thank you for understanding me. I clearly understand what differences between 3 methods.
Now I have some problems.
1) Can I build a project which read value from a text file then add a registry value.
I'm using a batch file to do it but it wouldbe better if AI can do it by itself. Because as you say, a registry value which create by installer can be remove during the rollback of the installation.
2) I have a vbs file which add some registry to restore default "Show / Hide Hidden Files and Folders".

Code: Select all

Option Explicit
Dim dblHiddenData, strHiddenKey, strSuperHiddenKey, strFileExtKey
Dim strKey, WshShell
On Error Resume Next

strKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
strHiddenKey = strKey & "\Hidden"
strSuperHiddenKey = strKey & "\ShowSuperHidden"
strFileExtKey = strKey & "\HideFileExt"

Set WshShell = WScript.CreateObject("WScript.Shell")
dblHiddenData = WshShell.RegRead(strHiddenKey)

WshShell.RegWrite strHiddenKey, 2, "REG_DWORD"
	WshShell.RegWrite strSuperHiddenKey, 0, "REG_DWORD"
	WshShell.RegWrite strFileExtKey, 1, "REG_DWORD"
If I run it manually, it work fine. But if I run it as attach file at custom action page, it not working properly. Can u tell me why? Thanks
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,
1) Can I build a project which read value from a text file then add a registry value.
I'm using a batch file to do it but it would be better if AI can do it by itself. Because as you say, a registry value which create by installer can be remove during the rollback of the installation.
I'm afraid that we do not have support for reading from a text file, so you can implement this only through your custom action. However, you can create a custom action that only reads from a text file and put the read values into installer properties, then use those properties in the Registry page to write their values to the registry.
2) I have a vbs file which add some registry to restore default "Show / Hide Hidden Files and Folders".
If I run it manually, it work fine. But if I run it as attach file at custom action page, it not working properly. Can u tell me why?
I tested your script code and it seems that the "Set WshShell = WScript.CreateObject("WScript.Shell")" line throws the error, so I modified that line as below and it worked in Advanced Installer, too:

Code: Select all

Set WshShell = CreateObject("WScript.Shell")
Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

Great!. .VBS Custom action work fine. Thank for your help, Eusebiu.
So now back to my first issue, here my way to add an registry value by batch file.
If using batch file to add reg value

Code: Select all

@echo off
for /f "tokens=3" %%a in ('bcdedit /create /d "Grub4DOS" /application BOOTSECTOR') do set guid=%%a 
echo %guid% > %homedrive%\ID.txt
reg add "HKLM\SOFTWARE\MY COMPANY\MY PRODUCT" /v ID /t REG_SZ /d %guid% /f
If using AI

Code: Select all

@echo off
for /f "tokens=3" %%a in ('bcdedit /create /d "Grub4DOS" /application BOOTSECTOR') do set guid=%%a 
echo %guid% >%homedrive%\ID.txt
After txt file was created, a "read .txt" custom action will be launched to read text from .txt file then create a PROPERTY to add registry. And I found somethings that I must do here http://www.advancedinstaller.com/forums ... 150#p61806.
Add a custom action which read .txt file:

Code: Select all

readFile= "path to ID.txt"
Const ForReading = 1

Set fso = CreateObject("Scripting.FileSystemObject") 
Set srcFile  = fso.OpenTextFile(readFile, ForReading, False)

Session.Property("ADDREG") = srcFile.ReadLine
then add launch attach batch file. Move "read .txt custom action" under "launch attach batch file" for sure that txt file was created before "read .txt custom action" launches.
Goto Registry Page, add reg with [ADDREG] at data field
Build and run the installer but it not working properly.
Please give me some suggestion if u know, thanks
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,

Your configurations seem to be done correctly, but I'm not sure why they do not work property. However, there may be many reasons:
- the .txt file should be created before the start of the "read .txt" custom action (without any delay)
- the custom actions should be placed before the "Add Resources" action group
- the [ADDREG] property should be created in the Install Parameters page

Can you please send us the .AIP (project file) and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

Hi,
Can you please check my project and correct the ones I got wrong?
Thanks
Attachments
Send.rar
(3.57 KiB) Downloaded 849 times
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,

I looked over your AIP and I found the following problems:
- the custom actions should be placed before the "Add Resources" action group
- your custom actions were placed after "Add Resources" action group
- the VBS custom action should be added using the "Launch attached package" custom action because it works with Windows Installer properties and cannot be executed outside the package

Please correct the above problems and the package will work.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Uninstall Cleanup for registry

Hi
Thanks for your quick response
Now I have another problems.
1) I get popup message : "Object required: 'Session' when run the installer.
2) I just ordered quick batch file compiler to convert batch file to exe. By this way, I can use "launch attach file" custom action. If I run .exe manually, it work fine. But if I use AI to run .exe file as attach file, I get this error.
"Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: exe, location: C:\Windows\Installer\MSI52D1.tmp, command: "
As I know, if a custom action launches error, I will get
Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor.
My batch

Code: Select all

@echo off
for /f "tokens=3" %%a in ('bcdedit /create /d "Grub4DOS" /application BOOTSECTOR') do set guid=%%a
echo %guid%> C:\ID.txt
And I attached .exe file (converted from my batch) too.
Could u tell me why? Thanks
Attachments
Setup_Batch.rar
(11.9 KiB) Downloaded 854 times
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Cleanup for registry

Hi,
1) I get popup message : "Object required: 'Session' when run the installer.
When I configured and tested your AIP file I didn't get that error, I'm not sure why you encounter it. I attached the modified AIP file, so you can test it on your machine.
2) I just ordered quick batch file compiler to convert batch file to exe. By this way, I can use "launch attach file" custom action. If I run .exe manually, it work fine. But if I use AI to run .exe file as attach file, I get this error.
First of all I wouldn't recommend using EXE files converted from batch files because they may cause problems. Secondly, I tested your EXE file, but it did not work on my machines, neither when I launched it out of Advanced Installer.

I would recommend you to use the batch file instead of the EXE file, by adding it in the Files and Folders page as a temporary file (using the [Temporary Files] toolbar button) and then use the "Launch File" custom action to execute it during the installation.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”