BitBanger
Posts: 9
Joined: Wed Jan 18, 2006 11:07 pm

Custom Action problems

I'm running 3.6.1 as a new user of Advanced Installer. I am trying to create a package that increments a registry entry on install and decrements it on uninstall.

I've been attempting to use custom actions to accomplish this by attaching a .VBS script that modifies the registry key. However every time I run the installer I get the following error:

---------------------
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.
---------------------

Currently the script is as follows:

Code: Select all

Function DeltaReg(delta)

Dim pathToKey, UseCount

	pathToKey =  "HKLM\Software\" + Session.Property("Manufacturer") + "/" + Session.Property("ProductName") + "Settings\UseCount"

	MsgBox pathToKey

	DeltaReg = 1
	Exit Function
End Function 
I've attached the action to the InstallFinalize stage, script type is set to VBS and the Function Name contains DeltaReg(1). Execution Properties is 'Synchronous execution, check return code ', Execution Options is 'Immediate execution ', and Scheduling Options is 'Always execute'.

I do not get a MsgBox. It in fact acts as if the script isn't available. I've even included the script as one of the files to be included in the distribution.

I'd appreciate a pointer to what I'm doing wrong.

Thanks
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi,

The problem resides in the script. You cannot pass any parameters to functions launched from inside a custom action. Instead you could use some properties that contain the values that you wanted to pass to the custom action, and use their values inside the function.

Here is a working version of the script:

Code: Select all

Function DeltaReg() 

   Dim pathToKey, UseCount 

   pathToKey =  "HKLM\Software\" + Session.Property("Manufacturer") + "/" + Session.Property("ProductName") + "Settings\UseCount" 

   MsgBox pathToKey 
   DeltaReg = 1 
   Exit Function 
End Function 
Also, when you configure the custom action, in the "Function Name" field enter just the name of the function e.g. "DeltaReg" (without the quotes).

Please let me know if you encounter any more problems,

Best regards,
Ciprian
Last edited by ciprian on Mon Jan 23, 2006 12:00 pm, edited 1 time in total.
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
BitBanger
Posts: 9
Joined: Wed Jan 18, 2006 11:07 pm

Thanks ciprian,

That helped getting a script that worked. From there I could add what I needed. My registry entry is getting incremented on install and decremented on uninstall.

Related to the script is what I wanted it for. I have a bunch of applications that are dependant upon an engine. I've already got the engine set up in the application MSI files as a requirement, so it gets installed if it doesn't already exist.

What I need to do now is make sure that the engine isn't uninstalled unless all the applications that depend upon it are uninstalled first. What I am attempting to do is to check the value of a 'searched' registry entry and fail the uninstall of the engine if that application count is greater than 0.

I set up a custom error message in the InstallValidate action with a condition of (REMOVE="ALL") AND (CONTENT_COUNT>0) where CONTENT_COUNT is a property 'searched' from the registry.

The result is not what I expected. The uninstall blows right through without any message regardless of what the registry entry is.
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi,

The problem resides in the way you set up the condition. Here is a working version.

(REMOVE="ALL") AND (CONTENT_COUNT > "#0")

When retrieving it from the registry, Windows Installer adds a prefix to the registry value, that identifies it's type. For DWORD it is "#".

For more details please see:
http://msdn.microsoft.com/library/defau ... _table.asp

Best regards,
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
BitBanger
Posts: 9
Joined: Wed Jan 18, 2006 11:07 pm

Thank you. That was what I needed.

Return to “Common Problems”