ISearchCondition

Declaration

ISearchCondition: IDispatch
Overview

This interface is used to read and modify a single search condition. ( It is exposed through IUnchainedPackage.InstallConditions and IUnchainedPackage.NewInstallCondition. ). .
Properties

String ConditionType
Gets or sets the type of search condition.
String SearchString
Gets or sets the search target associated with the
condition.
String MinVersion
Gets or sets the minimum accepted version.
String MaxVersion
Gets or sets the maximum accepted version.
String ReferenceContent
Gets or sets the reference value used by the
condition.
String ComparisonType
Gets or sets the comparison operator used by
RegValueContent conditions.
String CommandLine
Gets or sets additional command-line parameters used by
certain condition types
String Order
Gets or sets the evaluation order of the condition within the
prerequisite
Examples:

Example 1: File presence with a version range:
$pkg = $prereqs.NewUnchainedPackage("C:\Redist\MyTool.exe")
$pkg.InstallSchedule = "Before"
$c = $pkg.NewInstallCondition("FileVersionInFolder",
"[ProgramFiles64Folder]MyTool\bin\mytool.exe")
$c.MinVersion = "2.0.0"
$c.MaxVersion = "2.99.99"
Example 2: Registry value content with a comparison operator :
$c = $pkg.NewInstallCondition("RegistryValueContent",
"HKLM\SOFTWARE\MyCompany\MyTool\Installed")
$c.ComparisonType = "ExactMatch"
$c.ReferenceContent = "1"
Example 3: Registry key existence (32-bit hive):
$c = $pkg.NewInstallCondition("RegistryKeyExists",
"HKLM\SOFTWARE\MyCompany\LegacyApp")
Example 4: MSI product code check:
$c = $pkg.NewInstallCondition("MsiProductCode",
"{F0D2B3F4-AA38-43F5-9C0E-12345678ABCD}")
Example 5: MSIX package check:
$c = $pkg.NewInstallCondition("MsixPackage",
"Vendor.App_1.0.0.0_x64__abc")
Example 6: Custom search with a command lin
$c = $pkg.NewInstallCondition("CustomSearch",
"C:\Tools\probe.exe")
$c.CommandLine = "--check --quiet"
Example 7: Enumerate and reorder by inspecting Order :
foreach ($c in $pkg.InstallConditions | Sort-Object Order) {
"{0,3}: {1} -> {2}" -f $c.Order,
$c.ConditionType,
$c.SearchString
}
Example 8: Switch ConditionType after creation:
$c = $pkg.NewInstallCondition("File",
"C:\Windows\System32\kernel32.dll")
$c.ConditionType = "RegistryKeyExists"
$c.SearchString = "HKLM\SOFTWARE\MyCompany\MyTool"
Example 9: Remove a condition
$first = @($pkg.InstallConditions)[0]
$pkg.RemoveInstallCondition($first)