igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

VBS on uninstall doesn't work

Hello,

I defined an installer limited to basic user interface. I would like to backup one file from app directory on uninstall. I created a VBS and attached it as EXE with working directory in Install Execution Stage before "Remove Resources". The VBS is a part of installation, is not a temporary file. The script works standalone but not on uninstall of app. What am I doing wrong?

I attached aip file and uninstall log.

Kind regards,
Igor
Attachments
MSI197fe.LOG
(261.64 KiB) Downloaded 499 times
FF_ESR_Portable_setup.aip
(57.84 KiB) Downloaded 765 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VBS on uninstall doesn't work

Hi Igor,

I noticed you are using Advanced Installer 9.4 which has predefined support for this functionality. Instead of a .VBS custom action, why don't you try the more reliable and easy to use Persistence Operation from your file's context menu -> Properties -> Operations tab?

If you need the backup at uninstall time, you can set the condition to:

Code: Select all

REMOVE="ALL"
All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

Re: VBS on uninstall doesn't work

Hi Mihai,

this file doesn't exist during installation time. It will be created on first start of the app.

Greetings,
Igor
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VBS on uninstall doesn't work

I see, but you don't have to install the .VBS custom action file. The correct approach is to use an "Launch attached file" custom action or even a "Launch installed file" instead.

"Launch EXE with working directory" has a completely different intended functionality as described in the user guide. Is there a certain reason you're using this approach?

With an installed file resource, any custom action must be set after Install Execution Stage -> Add Resources action group with a "Deferred" execution option. This ensures the installer will have access to the installed file.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

Re: VBS on uninstall doesn't work

Hi Mihai,

I have already tried to use "Launch installed file". But I get an error that the file (the VBS) doesn't exist. At a execution time after Install Execution Stage -> Add Resources the App including VBS and the file to backup was already deleted from the disk by uninstall process.
The execution of my VBS must be done before the removal is performed.

Best regards,
Igor
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VBS on uninstall doesn't work

Hi Igor,

I'm not sure I completely understand what you are trying to achieve. Can you please describe the intended functionality step by step?

Here's a related older How do I prevent a file from being replaced by a newer version? article with a couple of samples that demonstrate how to achieve this, but I'm not sure it fits your current scenario.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

Re: VBS on uninstall doesn't work

Hi Mihai,

no problem, here is the description step by step:
- my new created MSI installs Firefox Portable Browser
- on first start of Firefox the data folder with Firefox profile will be created. This folder ist not a part of installation.
- within this folder is the bookmark file with user's bookmarks created and will be filled with bookmarks
- in case of problems with the application Firefox will the package be uninstalled including profile folder and of course bookmark file
- before this step is done I want to backup this file to save user's bookmarks and copy it back after re-install of the app
- I wrote a VBScript for this and attached it into MSI. The script should be executed on uninstall but before the entire app folder will be deleted

Best regards,
Igor
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VBS on uninstall doesn't work

Hi Igor,

In this case, there's no need to use custom behavior because Advanced Installer has predefined functionality to accomplish this.

Here's what you can try:
- add a search from the Search page which returns the path location of the folder which contains the user specific files
- create a property based folder using the search name public property
- set a preserve operation for that folder (context menu -> Properties -> Operations tab) with the following condition:

Code: Select all

OLDPRODUCTS
This way the contents of that folder will always be preserved during an upgrade.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

Re: VBS on uninstall doesn't work

Hi Mihai,

I will try it.

But is there maybe a problem with my VBScript? I get a script error message in uninstall log:

...
...
MSI (s) (40:50) [10:49:38:719]: Doing action: Lesezeichen_sichern.vbs
Aktion beendet um 10:49:38: ProcessComponents. Rückgabewert 1.
MSI (s) (40:04) [10:49:38:734]: Entering MsiProvideComponentFromDescriptor. Descriptor: T%i&7oT-C?kaTW(0fqX8Toolbox>M5KDYSUnf(HA*L[xeX)y, PathBuf: EFF340, pcchPathBuf: EFF33C, pcchArgsOffset: EFF294
MSI (s) (40:04) [10:49:38:734]: MsiProvideComponentFromDescriptor called for component {997FA962-E067-11D1-9396-00A0C90F27F9}: returning harcoded oleaut32.dll value
MSI (s) (40:04) [10:49:38:734]: MsiProvideComponentFromDescriptor is returning: 0
MSI (s) (40:04) [10:49:38:734]: Entering MsiProvideComponentFromDescriptor. Descriptor: T%i&7oT-C?kaTW(0fqX8Toolbox>M5KDYSUnf(HA*L[xeX)y, PathBuf: EFF2EC, pcchPathBuf: EFF2E8, pcchArgsOffset: EFF240
MSI (s) (40:04) [10:49:38:734]: MsiProvideComponentFromDescriptor called for component {997FA962-E067-11D1-9396-00A0C90F27F9}: returning harcoded oleaut32.dll value
MSI (s) (40:04) [10:49:38:734]: MsiProvideComponentFromDescriptor is returning: 0
Aktion gestartet um 10:49:38: Lesezeichen_sichern.vbs.
MSI (s) (40:04) [10:50:53:986]: Produkt: Mozilla Firefox ESR Portable -- Fehler 1720. Es liegt ein dieses Windows Installer-Paket betreffendes Problem vor. Ein für den Abschluss der Installation erforderliches Skript konnte nicht ausgeführt werden. Wenden Sie sich an das Supportpersonal oder den Hersteller des Pakets. Benutzerdefinierte Aktion: Lesezeichen_sichern.vbs Skriptfehler -2146827864, Laufzeitfehler in Microsoft VBScript: Objekt erforderlich: 'WScript' Zeile7, Spalte 1,
...
...

This is line 7 in my script:
...
set objShell = WScript.CreateObject("WScript.Shell")
...

Best regards,
Igor
igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

Re: VBS on uninstall doesn't work

Mihai,

your suggestion will not help me. In case of uninstall the folder with this file will be deleted. I will copy this file to another location on the disk before removal. After re-install this file can be copied back to the profile folder.

Best regards,
Igor
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VBS on uninstall doesn't work

Hi Igor,

The correct syntax would be:

Code: Select all

Set objShell = CreateObject("WScript.Shell")
Here's a FAQ that explains this.

However, this is irrelevant because it involves customizing the install sequence in order to have access to the resources at the proper time.
We recommend using the predefined approach. Custom actions have the purpose to accomplish unaccounted for scenarios, but the developer must have extensive knowledge of the standard actions and how Windows Installer works.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VBS on uninstall doesn't work

To preserve the folder on uninstall as well just create an appropriate condition. Something like:

Code: Select all

OLDPRODUCTS OR (REMOVE="ALL")
This way the folder content will be preserved when the package upgrades the existing installation or when it's simply uninstalled.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
igi
Posts: 47
Joined: Tue Nov 15, 2011 3:45 pm

Re: VBS on uninstall doesn't work

Thank you Mihai,

it works now.

Best regards,
Igor

Return to “Common Problems”