- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- How to access INSTALLDIR property with PowerShell and VBS CustomAction
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
How to access INSTALLDIR property with PowerShell and VBS CustomAction
How to access INSTALLDIR property with PowerShell and VBS CustomAction
Summary:
How to access INSTALLDIR property with PowerShell and VBS CustomAction
Symptoms:
This article explains how to use a powershell and Vbs custom action to access an INSTALLDIR property using custom action. This information applies to the following InstallShield project types:
- Basic MSI
- InstallScript MSI
Solution:
For Powershell CustomAction
- Create Basic MSI Project
- Go to CustomAction view
- Add a set property CustomAction and rename it "SetPropertyCA"
- Property Name SETCUSTOMINSTALLDIR and value set to [INSTALLDIR]
- Set InstallExec to After AppSearch
- Create a Powershell Customaction with stored in Binary table
- Browse and add the .ps1 file (save below code as Test.ps1)
- $Path = get-property -name SETCUSTOMINSTALLDIR
$wshell = New-Object -ComObject Wscript.Shell
New-Item $Path -ItemType "Directory"
$a = new-object -comobject wscript.shell
$b = $a.popup("INSTALLDIR: $Path",0,"Test Message Box",1)
#[System.Windows.MessageBox]::Show('Would you like to Install the Setup?','Setup input','YesNoCancel','Error')
#$msgBoxInput = [System.Windows.MessageBox]::Show($Path,'Game input','YesNoCancel','Error')
Start-Process -FilePath $Path\Notepad2.exe - Set InstallExec to After SetPropertyCA
- Save the project
- Build and Run the project.
Vbs CustomAction:
- Create Basic MSI Project
- Go to CustomAction view
- Add a Vbs Custom Action with stored in binary table option
- Browse and add your .vbs file (save below vbs file as installdir.vbs)
-
Function InstallDIRTest()
Dim INSTALLDIR, SRCDIR' first, path to the msi file
INSTALLDIR = Session.Property("INSTALLDIR")'MsgBox Session.Property("INSTALLDIR")
MsgBox "The value of INSTALLDIR is now " & session.Property("INSTALLDIR")
End Function ' InstallMySQL
- Set InstallExec to After InstallInitialize
- Set "use 64 bit scripting" option to YES.
- Save the project
- Build and Run the project.
Reference:
KB article to access MSI property with a deferred custom action
Installshield help document for INSTALLDIR Property in a VBScript Custom Action