Reputation: 1
I am hoping to write a very small VBScript in Wix 3.11 that checks if a particular registry entry has a value.
Basically, if HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell = "drive:\path\to\thisAppName.exe", we want to replace it with ours. We only need to know that thisAppName.exe is used as the current shell. (aka, a substring...) The Condition XML statement doesn't seem to support substring functionality.
When debugging the VBScript, the 'value' is always empty, and the session property value is empty. as well. This suggests to me that something is running out of sequence.
Due to small amount of scripting code, it makes sense to keep it in the Wix code. I'm hoping not to move this into a custom module, as this seems overkill for what is needed.
<Wix>
<Product>
...
<Property Id="SHELL_KEY">
<RegistrySearch Id="REG_SHELL_KEY" Root="HKLM"
Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Name="Shell"/>
</Property>
<CustomAction Id="REGISTRYKEYCHECK" Script="vbscript" Execute="immediate" Return="ignore">
<![CDATA[
Dim value
value = Session.Property("SHELL_KEY")
IF INSTR(value, "thisAppName.exe") > 0 THEN
Session.Property("RESET_SHELL_KEY") = "1"
END IF
]]>
</CustomAction>
<InstallExecuteSequence>
<Custom Action="REGISTRYKEYCHECK" Before="CostFinalize">1</Custom>
</InstallExecuteSequence>
...
<Directory>
...
<Component Id="ResetShellExe" Guid="{....}"
<Condition><![CDATA[RESET_SHELL_KEY]]</Condition>
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon">
<RegistryValue Type="string" Name="Shell" Value="$(var.MyProgram.TargetFileName)" KeyPath="no"/>
</RegistryKey>
</Component>
<Feature Id="Complete" Level="1">
...
<ComponentRef Id="ResetShellExe"/>
</Feature>
...
</Product>
</Wix>
Upvotes: 0
Views: 145
Reputation: 21886
VBScript isn't necessary because Windows Installer does support substrings.
Upvotes: 0