comt00006
asked on
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_HANDL E, "PROPERTYNAME", "its value");
Step 2:
--------
Read this from VBScript file
' This is the exact code
strValue = Session.Property("PROPERTY NAME")
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("PROPERTY NAME") = "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.
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_HANDL
Step 2:
--------
Read this from VBScript file
' This is the exact code
strValue = Session.Property("PROPERTY
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("PROPERTY
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.
ASKER
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.
Thanks
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.
Thanks
ASKER
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!!!
Thanks.
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!!!
Thanks.
ASKER
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/R oot")
' 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
Next
' Check if directory exists
If (blnDirExists) Then
' Delete the virtual Directory
oWebSiteRoot.Delete "IIsWebVirtualDir", "ROEA_DI"
oWebSiteRoot.SetInfo
' Create an instance of our FSO object
Set oFso = CreateObject("Scripting.Fi leSystemOb ject")
' Check if folder exists
If oFso.FolderExists(strPathN ame) 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.
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
' 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
Next
' Check if directory exists
If (blnDirExists) Then
' Delete the virtual Directory
oWebSiteRoot.Delete "IIsWebVirtualDir", "ROEA_DI"
oWebSiteRoot.SetInfo
' Create an instance of our FSO object
Set oFso = CreateObject("Scripting.Fi
' Check if folder exists
If oFso.FolderExists(strPathN
'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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
' ...do 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: http://www.installshield.com/news/newsletter/0308-articles/msi.asp
Hopefully this helps..