Old 27th October 2010, 19:41   #1
Sooz24
Junior Member
 
Join Date: Sep 2009
Posts: 7
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?
Sooz24 is offline   Reply With Quote
Old 27th October 2010, 19:50   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Since when did start menu folders have program specific icons (by default)?

Stu
Afrow UK is offline   Reply With Quote
Old 27th October 2010, 20:51   #3
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
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)
code:
[.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..

Last edited by Wizou; 27th October 2010 at 21:32.
Wizou is offline   Reply With Quote
Old 27th October 2010, 23:59   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
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)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th October 2010, 12:23   #5
jiake
Senior Member
 
jiake's Avatar
 
Join Date: Oct 2007
Location: Shanghai, China
Posts: 207
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.
jiake is offline   Reply With Quote
Old 31st October 2010, 06:14   #6
flizebogen
Senior Member
 
Join Date: Jan 2002
Location: Berlin
Posts: 172
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:

PHP Code:
!define PathMakeSystemFolder "!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 
flizebogen is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump