Hello - I am trying to register my portable OpenOffice apps on Win 10. What seemed like an easy task has me stumped! The apps are on drive P: (USB) and all I need to do is associate .odt; .odb; and .odg file types to the appropriate OpenOfficePortable.exe - e.g.
.odt to P:\OpenOfficePortable\OpenOfficeWriterPortable.exe
I've built a .nsi that includes FileAssociation.nsh, and tried both SetRegView to 32 and 64, but the ${RegisterExtension} "P:\OpenOfficePortable\OpenOfficeWriterPortable.exe" ".odt" "odt_file" changes nothing in the registry, even after a reboot.
I know I'm missing something here ... what?
Thanks for any help!
Win 10 File associations
4 posts
My .nsi script:
!include "FileAssociation.nsh"
Function .onInit
System::Call 'kernel32::CreateMutex(p 0, i 0, t "myMutex") p .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
MessageBox MB_YESNO "This will install PedsCare. Continue?" IDYES gogo
Abort
gogo:
FunctionEnd
Name "PedsCare"
OutFile "installer.exe"
SetFont /LANG=${LANG_ENGLISH} "Consolas" 18
Icon "P:\NSIS\Caduceus.ico"
Section "Installer Section"
SetRegView 64
${registerExtension} "P:\OpenOfficePortable\OpenOfficeDrawPortable.exe" ".odg" "odg_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeWriterPortable.exe" ".odt" "odt_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeBasePortable.exe" ".odb" "odb_file"
SetRegView 32
${registerExtension} "P:\OpenOfficePortable\OpenOfficeDrawPortable.exe" ".odg" "odg_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeWriterPortable.exe" ".odt" "odt_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeBasePortable.exe" ".odb" "odb_file"
SectionEnd
!include "FileAssociation.nsh"
Function .onInit
System::Call 'kernel32::CreateMutex(p 0, i 0, t "myMutex") p .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
MessageBox MB_YESNO "This will install PedsCare. Continue?" IDYES gogo
Abort
gogo:
FunctionEnd
Name "PedsCare"
OutFile "installer.exe"
SetFont /LANG=${LANG_ENGLISH} "Consolas" 18
Icon "P:\NSIS\Caduceus.ico"
Section "Installer Section"
SetRegView 64
${registerExtension} "P:\OpenOfficePortable\OpenOfficeDrawPortable.exe" ".odg" "odg_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeWriterPortable.exe" ".odt" "odt_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeBasePortable.exe" ".odb" "odb_file"
SetRegView 32
${registerExtension} "P:\OpenOfficePortable\OpenOfficeDrawPortable.exe" ".odg" "odg_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeWriterPortable.exe" ".odt" "odt_file"
${registerExtension} "P:\OpenOfficePortable\OpenOfficeBasePortable.exe" ".odb" "odb_file"
SectionEnd
Do you have "RequestExecutionLevel admin" in your script? FileAssociation.nsh tries to write to HKCR and you need to be admin to do that.
If you don't want to require UAC elevation then you must change all instances of HKCR ("HKCR $R0..." to "HKCU Sofware\Classes\$R0..." etc.) in FileAssociation.nsh.
Just keep in mind that Windows does not allow you to fully take over existing associations anymore, it might display a prompt when you try to open a file. See Changes to how Windows 10 handles default apps
If you don't want to require UAC elevation then you must change all instances of HKCR ("HKCR $R0..." to "HKCU Sofware\Classes\$R0..." etc.) in FileAssociation.nsh.
Just keep in mind that Windows does not allow you to fully take over existing associations anymore, it might display a prompt when you try to open a file. See Changes to how Windows 10 handles default apps
SOLVED! "RequestExecutionLevel admin" did the trick - thanks Anders