From NSIS documentation, we have
root_key subkey key_name
This attribute tells the installer to check a string in the registry, and use it for the install dir if that string is valid. If this attribute is present, it will override the InstallDir attribute if the registry key is valid, otherwise it will fall back to the InstallDir default.
So, if I have these lines in a .nsi
file:
InstallDir "D:\myFolder\myFile"
InstallDirRegKey HKCU "Software\${PRODUCT_COMPANY}\${PRODUCT_NAME}" "Install_Dir"
I understand that I set my install directory to D:\myFolder\myFile
as default directory, but if Software\${PRODUCT_COMPANY}\${PRODUCT_NAME}
is a valid path, then I will use it instead. Is that correct?
From another post, I understand that the InstallDirRegKey
instruction is used to overwrite previous installation at same location. How is it working more precisely? If I have the following,
InstallDir "D:\myFolder\myFile"
InstallDirRegKey HKCU "D:\myFolder\myFile" "Install_Dir"
will a new .exe
file generated by the NSIS script overwrite the previous one? Or does it mean that the executable will overwrite the previous one?