I needed a simple plugin for setting an app as default for its registered handlers on Vista so I created a wiki page for it in case it comes in handy for anyone else.
SetVistaDefaultApp_plug-in
http://nsis.sourceforge.net/SetVistaDefaultApp_plug-in
Set Vista default app
10 posts
The plugin has been updated to support all of the methods available with IApplicationAssociationRegistration
Application Association Registration plug-in
http://nsis.sourceforge.net/Application_Association_Registration_plug-in
Application Association Registration plug-in
http://nsis.sourceforge.net/Application_Association_Registration_plug-in
Thanks for sharing!
Can anyone confirm, that the NSIS plugin (Application Association Registration) fails in latest Windows 10 (18362.356)?
Fails how? It should not crash but Windows 10 does not allow apps to change the default, only the user can set default apps.
@Anders
I am using the following plugin in my installer code: https://nsis.sourceforge.io/mediawik...in&oldid=16469
This plugin allows me to set given app for given extension. It was working very nice.
Microsoft is trying to do everything to not allow to do this... I think, the plugin stopped working since last Windows 10 update...
When I call this (after adding all neccessary registry entries - see below in my macro):
Plugin help says:
Here is the macro I use to register extensions for given application (in below exaple I use AIMP as app and aac as registered extension)
This is how I call macro:
(First parameter (217) is item number in config INI file, where are stored all apps and extensions)
(Like in above example - make AIMP default app for aac extension - so, when user double click on aac file it will be opened in AIMP)
-Pawel
I am using the following plugin in my installer code: https://nsis.sourceforge.io/mediawik...in&oldid=16469
This plugin allows me to set given app for given extension. It was working very nice.
Microsoft is trying to do everything to not allow to do this... I think, the plugin stopped working since last Windows 10 update...
When I call this (after adding all neccessary registry entries - see below in my macro):
AppAssocReg::SetAppAsDefault "${NAME}" ".${EXT}" "file" what means here for example: AppAssocReg::SetAppAsDefault "AIMP" ".aac" "file" It should set AIMP default app for aac extension. As I said it was working - but today plugin fails...Plugin help says:
AppAssocReg::SetAppAsDefault app_name assoc_name type
Pop $Var
Sets an application as the default for the specified association name and type.
Returns:
'success' if the call was successful.
'method failed' if the call failed.
'method not available' if IApplicationAssociationRegistration is not available on the system. The problem is that now the plugin result is not any of above... just empty string... I was thinking maybe this is because Windows Defender, but probably Microsoft blocked this interface - IApplicationAssociationRegistration or something. Unfortunately I have no knowledge in this matter...Here is the macro I use to register extensions for given application (in below exaple I use AIMP as app and aac as registered extension)
This is how I call macro:
(First parameter (217) is item number in config INI file, where are stored all apps and extensions)
${MACRO_REGISTER_GIVEN_EXTENSION } "217" "$INSTDIR\PLUGINS\Media\AIMP\AIMP.exe" "$INSTDIR\PLUGINS\Media\AIMP\AIMP.exe,0" "aac" "AIMP Media Player" "AIMP" "" !define MACRO_REGISTER_GIVEN_EXTENSION "!insertmacro MACRO_REGISTER_GIVEN_EXTENSION"
!macro MACRO_REGISTER_GIVEN_EXTENSION NODE PATH ICONLIB EXT DESC NAME PARAM
Push $2 ; 1
Push $1 ; 2
Push $0 ; 3
${If} ${AtLeastWinVista} ; Windows 7
ReadIniStr $R0 "$PLUGINSDIR\Configs\INSTALLER_ASSOCIATIONS.ini" "Tree.Node${NODE}" "UserCheck" ; This config file contains apps with extensions
; Extension is registered if UserCheck = 1(this file - INSTALLER_ASSOCIATIONS.ini is populated on Custom Installer Page)
${If} $R0 == "1"
ReadRegStr "$0" "HKLM" "SOFTWARE\RegisteredApplications" "${NAME}"
${If} "$0" == ""
WriteRegStr "HKLM" "SOFTWARE\RegisteredApplications" "${NAME}" "SOFTWARE\Clients\Media\${NAME}\Capabilities"
WriteRegStr "HKLM" "SOFTWARE\Clients\Media\${NAME}" "" "${NAME}"
WriteRegStr "HKLM" "SOFTWARE\Clients\Media\${NAME}\Capabilities" "ApplicationName" "${NAME}"
WriteRegStr "HKLM" "SOFTWARE\Clients\Media\${NAME}\Capabilities" "ApplicationDescription" "${DESC}"
${EndIf}
WriteRegStr "HKLM" "SOFTWARE\Clients\Media\${NAME}\Capabilities\FileAssociations" ".${EXT}" "${NAME}.File.${EXT}"
WriteRegStr "HKLM" "SOFTWARE\Clients\Media\${NAME}\DefaultIcon" "" "${ICONLIB}"
WriteRegStr "HKLM" "SOFTWARE\Clients\Media\${NAME}\shell\open\command" "" '"${PATH}" ${PARAM} "%1"'
ReadRegStr "$0" "HKCR" ".${EXT}" ""
${If} "$0" != "" ; key exists
ReadRegStr "$1" "HKCR" ".${EXT}" "TCUP_Backup" ; check if we already backuped key
${If} "$1" == "" ; we did not
ReadRegStr "$2" "HKCR" ".${EXT}" "TCUP Extension" ; check if we created extension
${If} "$2" == "" ; "TCUP Extension" value not exists
WriteRegStr "HKCR" ".${EXT}" "TCUP_Backup" "$0" ; backup old key value
WriteRegStr "HKCR" ".${EXT}" "" "${NAME}.File.${EXT}" ; write new one
${EndIf}
WriteRegBin "HKCR" ".${EXT}\OpenWithProgIds" "${NAME}.File.${EXT}" ""
${EndIf}
${Else}
WriteRegStr "HKCR" ".${EXT}" "" "${NAME}.File.${EXT}" ; Create own value
WriteRegStr "HKCR" ".${EXT}" "TCUP Extension" "1" ; set is as our
WriteRegBin "HKCR" ".${EXT}\OpenWithProgIds" "${NAME}.File.${EXT}" ""
${EndIf}
WriteRegStr "HKCR" "${NAME}.File.${EXT}" "" ""
WriteRegStr "HKCR" "${NAME}.File.${EXT}\DefaultIcon" "" "${ICONLIB}"
WriteRegStr "HKCR" "${NAME}.File.${EXT}\shell" "" "Open"
WriteRegStr "HKCR" "${NAME}.File.${EXT}\shell\open\command" "" '"${PATH}" ${PARAM} "%1"'
AppAssocReg::SetAppAsDefault "${NAME}" ".${EXT}" "file"
Pop $1
DetailPrint "${NAME} :: Extension registration: .${EXT}"
DetailPrint "Program: ${NAME}" ; Program
DetailPrint "Description: ${DESC}" ; Desc
DetailPrint "Parameter: ${PARAM}" ; Param
DetailPrint "Extension: .${EXT}" ; Ext
DetailPrint "Path: ${PATH}" ; Path
DetailPrint "Icon library: ${ICONLIB}" ; Icon
${If} $1 == "success"
DetailPrint "Result: OK. Given extension has been correctly associated with program: '${NAME}'"
; Save result
WriteINIStr "$INSTALL_CONFIG_FILE" "${NAME} Extension" "${EXT}" "1"
${else}
DetailPrint "Result: Error! Extension registration failed..."
; Save result
WriteINIStr "$INSTALL_CONFIG_FILE" "${NAME} Extension" "${EXT}" "0"
${If} $1 == "method failed"
DetailPrint "Reason: Plugin Call Failed!"
${EndIf}
${If} $1 == "method not available"
DetailPrint "Reason: IApplicationAssociationRegistration is not available on the system!"
${EndIf}
${EndIf}
${Else}
; Save result
WriteINIStr "$INSTALL_CONFIG_FILE" "${NAME} Extension" "${EXT}" "0"
${EndIf}
${EndIf}
Pop $0
Pop $1
Pop $2
!macroend The question is how to register given extension for given app to be default.(Like in above example - make AIMP default app for aac extension - so, when user double click on aac file it will be opened in AIMP)
-Pawel
MSDN is very clear.
Note As of Windows 8, the only functionality of this interface that is supported is QueryCurrentDefault.And regarding default apps:
This topic does not apply for Windows 10. The way that default file associations work changed in Windows 10. For more information, see the section on Changes to how Windows 10 handles default apps in this post.
Yes, you are right. It should not work long time ago. But it was working on Windows 10.
@Anders,
One more question.
I need to register Internet Browser (Vivaldi or Opera, whatever) as system default browser in Windows 10 with my installer (in old Windows it was easy, but not in Win10). To do it, I add all needed entries to system registry (to know what entries need to be added I installed the browser on clean virtual system and set it as default) and opens system Settings applet.
I do it using the following code:
ExecShell "open" "$SYSDIR\control.exe" "/name Microsoft.DefaultPrograms /page pageDefaultProgram"
Finally I refresh the shell using this command:
System::Call "Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)"
This opens this page -> http://www.meggamusic.co.uk/shup/156...efaultApps.png
But, I would like to open this window: http://www.meggamusic.co.uk/shup/156...hooseAnApp.png
Vivaldi can do this... I wonder how to do this programatically (in NSIS).
Do you maybe know the answer? Or anyone?
-Pawel
One more question.
I need to register Internet Browser (Vivaldi or Opera, whatever) as system default browser in Windows 10 with my installer (in old Windows it was easy, but not in Win10). To do it, I add all needed entries to system registry (to know what entries need to be added I installed the browser on clean virtual system and set it as default) and opens system Settings applet.
I do it using the following code:
ExecShell "open" "$SYSDIR\control.exe" "/name Microsoft.DefaultPrograms /page pageDefaultProgram"
Finally I refresh the shell using this command:
System::Call "Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)"
This opens this page -> http://www.meggamusic.co.uk/shup/156...efaultApps.png
But, I would like to open this window: http://www.meggamusic.co.uk/shup/156...hooseAnApp.png
Vivaldi can do this... I wonder how to do this programatically (in NSIS).
Do you maybe know the answer? Or anyone?
-Pawel