I have an Installshield project with powershell CA that checks if certain registry key exists and set a property base on the result.
The registry check succeeded when executing the script manually but failed (return false
when get executed from Installshield.
** The CA is being executed during the UI sequence (before the ExecuteAction
step) - is this a problem?
How can I solve this issue? Is there an alternative way to check for existation of registry key with powershell custom action?
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
$keyName = "AutoAdminLogon"
if (Test-Path $registryPath)
{
# The following line returns FALSE when executed during installation and TRUE when executed manually.
$valueExists = (Get-ItemProperty $registryPath).PSObject.Properties.Name -contains $keyName
if ($valueExists)
{
# Set property to be read in installshield
Set-Property -Name IS_AUTO_LOGON -Value 2
}
else
{
Set-Property -Name IS_AUTO_LOGON -Value 1
}
}
There is no need to do this with Powershell. Windows installer can do this natively with the RegLocator table.
Solved:
Installshield indeed opens up the 32 bit version of powershell. So I simply asked to get the 64 bit version of the registry at the beginning of the script and then checked if the required key is there.
In order to get the 64 bit version of registry and search for my key I used: