Skip to content

$cs.MSI_IsMSIGuidInstalled

Checks whether a product with the given ProductCode GUID is currently installed, by querying Windows Installer’s product state directly — no MSI file needed, just the GUID. Windows-only.

$cs.MSI_IsMSIGuidInstalled(string msiguid)

ProductCode GUID to check the installation status of.

Boolean, $true if a product with this GUID is installed. Returns $false on any error rather than throwing.

Terminal window
if ($cs.MSI_IsMSIGuidInstalled('{AC76BA86-1033-FF00-7760-BC15014EA700}')) {
$cs.Job_WriteLog("Product is already installed, skipping install")
}

Use the same guard with a hardcoded GUID inside PreInstall, which is useful when the kit downloads its MSI separately at install time rather than shipping it in the package:

Terminal window
function PreInstall {
$cs.Log_SectionHeader('PreInstall', 'o')
$knownProductCode = '{AC76BA86-1033-FF00-7760-BC15014EA700}'
if ($cs.MSI_IsMSIGuidInstalled($knownProductCode)) {
Exit-PSScript -exitcode 3330 -exitmessage "$global:AppName ($knownProductCode) is already installed, nothing to do"
}
}

$cs.MSI_GetProductCodeFromMSI $cs.MSI_IsMSIFileInstalled