Archive: Icon for a Start Menu item generated by CreateDirectory


Icon for a Start Menu item generated by CreateDirectory
  I'm sure there is a simple answer to this...

I have an install that creates the following entries in the Start Menu

MyApp
Run MyApp
Uninstall MyApp

Both Run MyApp and Uninstall MyApp correctly show their icons. The parent 'MyApp' does not.

I'm using the following definition
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\MyApp.lnk" "$INSTDIR\System\MyApp.exe" \
" " "$INSTDIR\System\MyApp.ico" "" SW_SHOWMINIMIZED
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall MyApp.lnk" "$INSTDIR\Uninstall.exe" \
" " "$INSTDIR\System\MyApp.ico" ""

How do I specify the missing icon?


Since when did start menu folders have program specific icons (by default)?

Stu


It is possible by placing a desktop.ini file in your folder. Give the file the attributes "hidden" and "system".
Inside desktop.ini, write the following: (with your NSIS script, so you can use the $INSTDIR)

[.ShellClassInfo]
IconResource=C:\YourPath\MyProgram.exe,0

(you can use an EXE, DLL or ICO file. See also http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx)

Apparently, you must also set the attribute "Read-only" on your folder. (only, not on the files inside)

And please make sure your custom folder icon still looks like a folder, otherwise the user would feel strange..

I think the attributes you need to set can vary (IIRC there is a registry setting for it) and the page you link to tells you which documented function to call (Or just set system and read-only to be on the safe side)


Maybe he said that one of the shortcuts created in start menu folder by his installer doesn't have an icon, that likes an executable file without any icon resource. He wants to show the icon he set in script.


Making Icons for folders is a nice thing especially in a corporate environment. This way users can distinguish between start menu entries provided by IT department from the rest.

I ues this construct fairly often, it even works with limited user rights:


"!insertmacro PATH_MAKE_SYSTEM_FOLDER"

>!macro PATH_MAKE_SYSTEM_FOLDER pszPath
System
::Call "shlwapi::PathMakeSystemFolder(t '${pszPath}') i."
>!macroend

Section "Make Shortcuts"
WriteINIStr "$SMPROGRAMS\Some Folder\Desktop.ini" ".ShellClassInfo" "IconFile" "$SYSDIR\shell32.dll"
WriteINIStr "$SMPROGRAMS\Some Folder\Desktop.ini" ".ShellClassInfo" "IconIndex" "188"
${PathMakeSystemFolder} "$SMPROGRAMS\Some Folder"
>SectionEnd
>