pkimike
Posts: 8
Joined: Mon Feb 21, 2022 9:33 pm

Need dialog to conditionally appear for new installs and upgrades

I have a requirement to present the user with a dialog to capture the FQDN of the local server. Since this requirement is net-new, it needs to appear for new installs as well as for upgrades.

It needs to appear in the following scenarios:
- The appSettings.OnPremises.json file doesn't exist
- The appSettings.OnPremises.json file but it contains "http://localhost".

To that end, I created the following custom action, which sets the property NEED_API_URL_SET to "true" if either of the above conditions exist:

Code: Select all

param ($WinVolume)

$logPath = Join-Path $env:TEMP "ai_fqdn_check.log"

function Log($message) {
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    "$timestamp - $message" | Out-File -FilePath $logPath -Append -Encoding utf8
}

Log "=== Starting custom action to check appSettings.onPremises.json ==="

$IsIISEnabled = Get-WmiObject -Query "Select Name FROM Win32_Service where name='W3svc'"
if ($IsIISEnabled) {
    Log "IIS service detected."
    $wwwRootReg = Get-ItemProperty HKLM:\Software\Microsoft\INetStp -Name "PathWWWRoot"
    $wwwRootPath = ($wwwRootReg.PathWWWRoot).TrimEnd("/","\")
    Log "Resolved wwwRootPath from registry: $wwwRootPath"
} else {
    Log "IIS not enabled, defaulting wwwRootPath."
    $wwwRootPath = Join-Path $WinVolume 'inetpub\wwwroot'
    Log "Using default wwwRootPath: $wwwRootPath"
}

AI_SetMsiProperty WWWROOT $wwwRootPath
AI_SetMsiProperty NEED_API_URL_SET ""
$targetPath = Join-Path $wwwRootPath "pkispotlight\appSettings.onPremises.json"
Log "Target file path: $targetPath"

if (Test-Path $targetPath) {
    Log "File exists. Reading content..."
    $content = Get-Content -Path $targetPath
    if ($content | Where-Object { $_ -like '*http://localhost/*' }) {
        Log "Found 'http://localhost' in file. Setting NEED_API_URL_SET to true."
        AI_SetMsiProperty NEED_API_URL_SET "true"
    } else {
        Log "'http://localhost' not found in file."
    }
} else {
    Log "File does not exist. Setting NEED_API_URL_SET to true."
    AI_SetMsiProperty NEED_API_URL_SET "true"
}

Log "=== Finished custom action ===`n"
I am trying to use the NEED_API_URL_SET property to have the ApiFqdnDlg dialog appear after the license agreement screen if it is "true". Here is the logic I have:
Image

(FolderDlg only needs to appear for new installs, so I can't bury ApiFqdnDlg under there.)

When I run the built MSI in upgrade mode, I can tell that my custom action is executing and working as expected because the log file is generated before the welcome screen appears:

Code: Select all

2025-05-29 12:42:10 - === Starting custom action to check appSettings.onPremises.json ===
2025-05-29 12:42:11 - IIS service detected.
2025-05-29 12:42:11 - Resolved wwwRootPath from registry: C:\inetpub\wwwroot
2025-05-29 12:42:11 - Target file path: C:\inetpub\wwwroot\pkispotlight\appSettings.onPremises.json
2025-05-29 12:42:11 - File exists. Reading content...
2025-05-29 12:42:11 - Found 'http://localhost' in file. Setting NEED_API_URL_SET to true.
2025-05-29 12:42:11 - === Finished custom action ===
However, when I click Next on the license screen, it still skips right to VerifyReadyDlg.

Can you tell what I am doing wrong?
Catalin
Posts: 7794
Joined: Wed Jun 13, 2018 7:49 am

Re: Need dialog to conditionally appear for new installs and upgrades

Hello,

I can't say for sure why this is happening.

If possible, could you please forward me a copy of your AIP file by email at support at advancedinstaller dot com so I can further investigate its settings?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”