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!

Trick

VBS as Custom Action

Hi AI,

I'm trying to write a small VBS to cleanup a couple of files that get created at runtime by my application, when it's uninstalled.

I'm trying to work out how I can find out the value of [TARGETDIR], in order to test for the files existance and remove accordingly.

I thought I might be able to pass in [TARGETDIR] as a parameter to the function call but it doesn't seem to work.

VBS:

Code: Select all

Function Cleanup (targetDir)
  MsgBox(targetDir)
End Function
Function Name:

Code: Select all

Cleanup("[TARGETDIR]")
or

Code: Select all

Cleanup([TARGETDIR])
or various other syntax attempts.

How can I find out the [TARGETDIR] from within my VBS code?

Regards,

Richard.
dorel
Posts: 25
Joined: Mon Oct 18, 2004 8:13 am

Hi Richard,

To accomplish your goal you need to create two custom actions.

First is your vbscript custom action in the uninstall sequence. Do not pas any parameters to the function you call from vbscript.

The second is of type "Property set with Formatted" and is scheduled before the Uninstall sequence - after MsiUnpublishAssemblies is ok - and has the following parameters:

Property Name = the exact name of your vbscipt custom action scheduled in the uninstall sequence.
Formatted Text = [TARGETDIR]

Now inside your vbscript custom action use the following code to retrive
the value of TARGETDIR:

Code: Select all

 appFolder = Session.Property("CustomActionData") 
Dorel Pislan
Advanced Installer Team
http://www.advancedinstaller.com
Guest

Hi Dorel,

Thank you for the information, I've now implemented your instructions and tested sucessfully :)

Regards,

Richard.

Return to “Common Problems”