InstallShield MsiSetProperty and MsiGetProperty

Posted on 2004-11-18
Last Modified: 2013-11-14
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.
Question by:comt00006
    LVL 3

    Expert Comment

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

    Author Comment

    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.

    LVL 1

    Author Comment

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

    LVL 1

    Author Comment

    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.

    Accepted Solution

    PAQed with points refunded (125)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now