Windows 7 Cascading Context Menu: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
Line 19: Line 19:
;menu-name,submenu,icon
;menu-name,submenu,icon
WriteRegStr HKCR "*\shell\NSIS.Script" "MUIVerb" "NSIS"
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "MUIVerb" "NSIS"
WriteRegStr HKCR "*\shell\NSIS.Script" "ExtendedSubCommandsKey" "NSIS.Script\W7Menu"
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "ExtendedSubCommandsKey" "NSIS.Script\W7Menu"
WriteRegStr HKCR "*\shell\NSIS.Script" "Icon" "$INSTDIR\makensisw.exe,1"
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "Icon" "$INSTDIR\makensisw.exe,1"
;compile
;compile

Revision as of 10:37, 14 September 2011

Description

As of Windows 7, one can create cascading context menus through the registry.

Example Script

This example creates entries for the NSIS compiler for all file-types. It is yet uncertain if this can be limited to a single filetype only.

Name "NSIS Window 7 Context Menu"
OutFile "nsW7Menu.exe"
RequestExecutionLevel admin
 
InstallDir $PROGRAMFILES\NSIS
InstallDirRegKey HKLM Software\NSIS ""
 
; Pages
Page directory
Page instfiles
 
; Sections
Section ""
 
	;menu-name,submenu,icon
	WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "MUIVerb" "NSIS"
	WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "ExtendedSubCommandsKey" "NSIS.Script\W7Menu"
	WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "Icon" "$INSTDIR\makensisw.exe,1"
 
	;compile
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile" "MUIVerb" "Compile NSIS Script"
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile\command" "" '"$INSTDIR\makensisw.exe" "%1"'
 
	;compile (choose compressor)
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile-compressor" "MUIVerb" "Compile NSIS Script (Choose Compressor)"
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile-compressor\command" "" '"$INSTDIR\makensisw.exe" /ChooseCompressor "%1"'
 
	;repeat for Unicode NSIS
	IfFileExists "$INSTDIR\Unicode\makensisw.exe" 0 End		
 
	;add separator above the next entry
	WriteRegDWORD HKCR "NSIS.Script\W7Menu\shell\ucompile" "CommandFlags" "32"
 
	;compile unicode
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile" "MUIVerb" "Compile Unicode NSIS Script"
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile\command" "" '"$INSTDIR\Unicode\makensisw.exe" "%1"'
 
	;compile unicode (choose compressor)
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile-compressor" "MUIVerb" "Compile Unicode NSIS Script (Choose Compressor)"
	WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile-compressor\command" "" '"$INSTDIR\Unicode\makensisw.exe" /ChooseCompressor "%1"'
 
	End:
 
SectionEnd

Alternative Method

The MSDN forums mention an alternative method for creating cascading menus. This will create keys in the CommandStore (HKLM) rather than in HKCR.

Links

MSDN
NSIS Discussion