InstallShield MsiSetProperty and MsiGetProperty

Hi there.

I know I am asking an INstallShield question in the Programming section but no section exists for InstallShield (I THINK!!!). It is kinda hard to find some stuff on this site.

Here is what I am trying to do.

Step 1:
From InstallShield script, set a preoprty value.

// I am using this exact code
MsiSetProperty(ISMSI_HANDLE, "PROPERTYNAME", "its value");

Step 2:
Read this from VBScript file

' This is the exact code
strValue = Session.Property("PROPERTYNAME")
MsgBox strValue

This gives me the following Error:
ERROR: Object required: 'Session'
Code:     800A01A8
Source:  Microsoft VBScript runtime error

Step 3:
Then I tried to assign a value in the VBScript file.

' This is the exact code
Session.Property("PROPERTYNAME") = "HALLO"

This gives me the same Error:
ERROR: Object required: 'Session'
Code:     800A01A8
Source:  Microsoft VBScript runtime error

All that I am trying to do is return a string value from VBScript to InstallShield.

If anyone could help me I would appreciate it.

Thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

are you calling a vbscript function from within inside of installshield script?

If you do that, you can set the function return value just like you would do with any function.

In VBScript code, a function can return IDABORT, with value 3, to exit an installation. The main limitation to be aware of is that VBScript actions with code stored directly in the CustomAction table cannot return a specific value. Instead, only VBScript custom actions with code stored in a VBS file, whether stored in the Binary table or installed with the product, can define functions that return a specific value.

For example, the following VBScript function returns IDABORT to exit the installation.

Function ExitSetupFromVBS( )
Const IDABORT = 3
' some work...
' abort the installation
ExitSetupFromVBS = IDABORT
End Function

Using the Custom Action
To use the custom action, first place its code in a source file called (for example) exitsetup.vbs. Next, define the custom action in Developer's Custom Actions view as follows.

Right-click the Custom Actions icon and select New VBScript > Stored in the Binary table.

Rename the new action icon to (for example) "exitsetup".

In the VBScript Filename field, browse for the file exitsetup.vbs.

In the Script Function field, enter the function name ExitSetupFromVBS.

Schedule the action in one of the sequences. For example, in the Install UI Sequence field, select After SetupInitialization.
After building and running the installation, the setup should exit when the custom action is encountered. As with any action, you can attach a condition to these custom actions, to abort the installation only under desired circumstances.

For more information, see the MSI Help Library pages "Custom Action Return Values" and "Return Values of JScript and VBScript Custom Actions".

Which comes from:

Hopefully this helps..
comt00006Author Commented:
Hi CAVcc

I am not trying to abort any installation. I am trying to access a STRING value that I get from my VBScript back to InstallShield script to use. It will be a path to a virtual directory files. I need it to delete them.

comt00006Author Commented:
Hi again

Here would be another solution to my problem.

Is there a way of getting a virtual directory's path by name through Installshield?

If I can get this then I would be all set because all I have to do is get rid of a virtual directory and delete all the containing files and folders. I am deleting the virtual directory using VBScript and also get the path through the same script but cannot return the path. That is where my problem is. I NEED THE PATH OF MY VIRTUAL DIRECTORY SO I CAN DELETE ALL!!!

comt00006Author Commented:
I have done what I wanted to do by using the FSO object. Here is my script:

Dim oWebSiteRoot
Dim oVirtDir
Dim blnDirExists
Dim strPathName
Dim oFso

On Error Resume Next

' Initialize our boolean variable
blnDirExists = False

' Set our virtual directory object
Set oWebSiteRoot = getobject("IIS://localhost/W3SVC/1/Root")

' Loop through the virtual directories
For Each oVirtDir in oWebSiteRoot

      ' Check for the type of directory
      if (oVirtDir.Class = "IIsWebVirtualDir") Then
            ' Check for the ROEA_DI directory
            if(InStr(1, oVirtDir.path, "ROEA_DI") > 0) then
                  blnDirExists = True
                  strPathName = oVirtDir.path
            end if
      End If
' Check if directory exists
If (blnDirExists) Then

      ' Delete the virtual Directory
      oWebSiteRoot.Delete "IIsWebVirtualDir", "ROEA_DI"

      ' Create an instance of our FSO object      
      Set oFso = CreateObject("Scripting.FileSystemObject")
      ' Check if folder exists
      If oFso.FolderExists(strPathName) Then
            'Setting the 2nd parameter to true
            'forces deletion of read-only files
            oFso.DeleteFolder strPathName, True
      End If
End If

This works like a charm.

Have a good one.
PAQed with points refunded (125)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.