VB Script Custom Action - 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!

viral
Posts: 22
Joined: Thu Jun 23, 2011 9:07 am

VB Script Custom Action

Hi,

I want to check whether database name entered by user is already exists or not using VBScript custom action. I have created ScriptInline custom action for this.
I am able to get all the database names in sql server by Session.Property("SqlServerDatabases"). Now I want to check whether database name (DATABASE_PROP)
exists in the Session.Property("SqlServerDatabases") or not. Below is my scriptinline code. But every time If condition is always evaluated to false even if I entered existing database name.

m = Split(Session.Property("SqlServerDatabases"),","):for each c in m:If CStr(c) = CStr(Session.Property("DATABASE_NAME")) Then:MsgBox("Database name exists"):Set Session.Property("DATABASENAME_ISVALID") = 0:End If:next

One more thing: Is there any limit in length of VB script text? Because VBScript text is cut in the custom action Script Text text box.

Please help me to solve my problem

Thanks,
Viral
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VB Script Custom Action

Hi Viral and welcome to the Advanced Installer Forums,

Unfortunately, our support boundaries do not cover debugging or creating custom actions. However, here is a good place to start. You can find sample code, tutorials or other resources that will help you define an algorithm which checks if a property is contained within another.
Also, you can debug your custom action using MsgBox occurrences :

Code: Select all

MsgBox Session.Property("YOUR_PROPERTY");
One more thing: Is there any limit in length of VB script text? Because VBScript text is cut in the custom action Script Text text box.
There is no limit, usually this script is made up of a single line. If it is longer and needs to be placed on several lines just edit the "Script Text" field with the body of the script and use the ":" character (without the quotes) to mark the place where a line ends and another begins. If you want to organize your VBScript code with a better overall view, you can write it to a .VBS file and add the file as an "Attached custom action".

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
viral
Posts: 22
Joined: Thu Jun 23, 2011 9:07 am

Re: VB Script Custom Action

Hi Mihai,

Thanks for your quick reply.

My question is that VBScript is running fine if I run it in html page. Problem only occurs when I implement it in advanced installer. I did debug my script using MsgBox as you said. I am able to get all the database name after splitting the Session.Property("SqlServerDatabases") by comma. Now when I compare the database name (DATABASE_PROP) to existing database name like

m = Split(Session.Property("SqlServerDatabases"),","):for each c in m:If CStr(c) = CStr(Session.Property("DATABASE_NAME"))

then if condition always evaluated to false even though both values are same. Same thing work fine in html page.

Thanks,
Viral
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: VB Script Custom Action

Hello Viral,

This can happen if your custom action is set with "Deferred" execution option. Here is an article that explains how a deferred custom action can access properties.

You can try to change it to "Immediate" to fix this.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
viral
Posts: 22
Joined: Thu Jun 23, 2011 9:07 am

Re: VB Script Custom Action

Hello Mihai,

Execution option is "Immediate" only and I am also able to get value of public property in script. I am only getting problem when I compare two strings in vb script.

m = Split(Session.Property("SqlServerDatabases"),","):for each c in m:If CStr(c) = CStr(Session.Property("DATABASE_NAME")) Then:MsgBox("Database name exists"):Set Session.Property("DATABASENAME_ISVALID") = 0:End If:next

In the above script, I am getting value of CStr(c) and Session.Property["DATABASE_PROP"]. And I am sure both values are same but IF condition always evaluated to false.

This script work well in HTML page.

Thanks
-Viral
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: VB Script Custom Action

Hi Viral

Can you please try using the function "StrComp", and do not use "CStr", as described in the following article.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
viral
Posts: 22
Joined: Thu Jun 23, 2011 9:07 am

Re: VB Script Custom Action

Thanks Bordon.

That solved my problem. :D

Viral

Return to “Common Problems”