VBScript custom action fails - 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!

T_N_T
Posts: 2
Joined: Fri Nov 13, 2009 8:55 am

VBScript custom action fails

Hello,

I am testing Advanced Installer 7.3. I am trying to add a vbs custom action to the uninstall section, but it fails with the following error message.

Image

I tried both "attached custom action" and "installed custom action". For execution properties, execution options, scheduling options I use the default settings. I just point to the *.vbs file and leave the rest as is. My script intends to remove some folders during uninstall. I prefer to use a script for this task, because using RemoveFiles table would be very messy (deleting the contents of hundreds of subfolders) and I cannot find another msi solution. My script works the way it should when I run it but it fails when it is included in msi setup.


The script is as follows:

Code: Select all

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

Function DeleteTheFolder(folder)
     Set fso = CreateObject("Scripting.FileSystemObject")
     If fso.FolderExists(folder) Then 
        fso.DeleteFolder(folder)
     End If 
End Function

f_1 = "%WINDIR%\Sun"
f_2 = "%APPDATA%\Sun"
f_3 = "%USERPROFILE%\Local Settings\Application Data\Sun"
f_4 = "%USERPROFILE%\AppData\Local\Sun"
f_5 = "%USERPROFILE%\AppData\LocalLow\Sun"

t_1 = WshShell.ExpandEnvironmentStrings(f_1)
t_2 = WshShell.ExpandEnvironmentStrings(f_2)
t_3 = WshShell.ExpandEnvironmentStrings(f_3)
t_4 = WshShell.ExpandEnvironmentStrings(f_4)
t_5 = WshShell.ExpandEnvironmentStrings(f_5)

DeleteTheFolder(t_1)
DeleteTheFolder(t_2)
DeleteTheFolder(t_3)
DeleteTheFolder(t_4)
DeleteTheFolder(t_5)
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: VBScript custom action fails

Hello,

Please note that the WScript object is not accessible from a vbscript running as a Windows Installer Custom Action. You can try assigning those environment variables to a property, then accessing that property from your script using Session.Property("PROPERTYNAME").

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
T_N_T
Posts: 2
Joined: Fri Nov 13, 2009 8:55 am

Re: VBScript custom action fails

Thank you. I didn't know that I could access windows installer properties from custom action scripts. In a biref test I could access system folder properties using the "immediate execution" option. (I learned that for deferred custom action scripts, these properties are not available.) I think I will be able to do what I want. Thanks again. :)

Regards

Return to “Common Problems”