Stuck with if statements in actionscript

Hi All

We have 4 different version of a particular application on Windows 2008~2019 Servers that I need to uninstall via a single fixlet that then needs to be added to a baseline for our patching guys to run with.

Was thinking I could use elseif to step through the possible registry values in my action script so I could specify the required uninstall key as per this doco;

https://developer.bigfix.com/action-script/reference/flow-control/if-elseif-else-endif.html

I seem to be missing the mark here. Anyone able to provide feedback on what section(s) I’m going wrong here?

if {exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{MyKey1}” of registry}

delete __createfile
createfile until END
MsiExec /X{{MyKey1} /qn REBOOT=reallysuppress

END
delete uninstall.bat
move __createfile uninstall.bat
waithidden uninstall.bat

elseif {exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{MyKey2}” of registry}

delete __createfile
createfile until END
MsiExec /X{{MyKey2} /qn REBOOT=reallysuppress

END
delete uninstall.bat
move __createfile uninstall.bat
waithidden uninstall.bat

elseif {exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{MyKey3}” of registry

delete __createfile
createfile until END
MsiExec /X{{MyKey3} /qn REBOOT=reallysuppress

END
delete uninstall.bat
move __createfile uninstall.bat
waithidden uninstall.bat

elseif {exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{MyKey4}” of registry

delete __createfile
createfile until END
MsiExec /X{{MyKey4} /qn REBOOT=reallysuppress

END
delete uninstall.bat
move __createfile uninstall.bat
waithidden uninstall.bat

endif

action requires restart “CrapApp_Uninstalled”

Is it just the missing backslashes after Uninstall and before your key names?

1 Like

No, that’s not all, sorry. The usage of a } as a literal inside a relevance substitution needs to be escaped as }} to prevent it from ending the substitution early.

See Tip: Escaping curly brackets for substitutions in ActionScript for more discussion on escaping { and } when needed.

Thanks very much Jason, you are right. After all that, it was decided they wanted one fixlet per version anyway so they could see more readily what was failing from action info. Thanks for your help anyway, was spot on.