Old 11th May 2006, 01:27   #1
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
How can I add a shortcut to Startup folder?

Hello,

I am wondering how I add a shortcut of my program to Startup folder?

Please help. Thanks.
Angry Coder is offline   Reply With Quote
Old 11th May 2006, 01:57   #2
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
code:

CreateShortCut "$SMPROGRAMS\Startup\My Program.lnk" "$INSTDIR\My Program.exe" \
"some command line parameters" "$INSTDIR\My Program.exe" 2 SW_SHOWNORMAL \
ALT|CTRL|SHIFT|F5 "a description"


A Few notes:
  • $SMPROGRRAMS is a constant for the programs folder under the start menu. Default is for the user's start menu. For all users, use SetShellVarContext. Refer to NSIS help for more info
  • The example CreateShortcut command is from the help files. For a complete list of all the options, refer to NSIS help files
Comperio is offline   Reply With Quote
Old 11th May 2006, 02:14   #3
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
Thanks!

What's "some command line parameters" or "a description"?

Should I leave it as is?
Angry Coder is offline   Reply With Quote
Old 11th May 2006, 02:20   #4
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
"some command line parameters"
This would be extra command line parmaters for the EXE. Normally, this would be null ("").

"a desciption"
This can be anything you want. It just serves as a way to describe the shortcut. It can be blank if you wish.
Comperio is offline   Reply With Quote
Old 11th May 2006, 02:51   #5
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
Really appreciate your help. Thanks
Angry Coder is offline   Reply With Quote
Old 11th May 2006, 03:05   #6
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
But the shortcut icon is not showing. I am getting the default windows exe icon

What's wrong?
Angry Coder is offline   Reply With Quote
Old 11th May 2006, 04:19   #7
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 853
Keep it simple:
code:
CreateShortCut "$SMPROGRAMS\Startup\My Program.lnk" "$INSTDIR\My Program.exe"

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 11th May 2006, 09:21   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,576
the correct folder variable is $SMSTARTUP not $SMPROGRAMS\Startup so the instructions should be: CreateShortCut "$SMSTARTUP\My Program.lnk" "$INSTDIR\My Program.exe"

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th May 2006, 21:47   #9
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 853
Good point. Our mistake.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 11th May 2006, 22:54   #10
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
Thanks guys for your follow-ups. But as I have mentionned:

The shortcut icon is not showing. I am getting the default windows exe icon... What's wrong?
Angry Coder is offline   Reply With Quote
Old 12th May 2006, 01:57   #11
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Is it just the icon that is messed up or is the entire shortcut screwed up? What was the exact command you used in your script?
Comperio is offline   Reply With Quote
Old 12th May 2006, 02:02   #12
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
Everything is working fine, but the icon is not showing up.

SetShellVarContext all

CreateShortCut "$SMSTARTUP\my prog.lnk" "$INSTDIR\my prog.exe" \
"" "$INSTDIR\my prog.exe" 2 SW_SHOWNORMAL \
ALT|CTRL|SHIFT|F5 "Do not delete this shortcut!"

I found this on the manual but I didn't get it.

Quote:
4.9.3.4 CreateShortCut
link.lnk target.file [parameters [icon.file [icon_index_number [start_options [keyboard_shortcut [description]]]]]]
Creates a shortcut 'link.lnk' that links to 'target.file', with optional parameters 'parameters'. The icon used for the shortcut is 'icon.file,icon_index_number'; for default icon settings use empty strings for both icon.file and icon_index_number. start_options should be one of: SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED, or an empty string. keyboard_shortcut should be in the form of 'flag|c' where flag can be a combination (using |) of: ALT, CONTROL, EXT, or SHIFT. c is the character to use (a-z, A-Z, 0-9, F1-F24, etc). Note that no spaces are allowed in this string. A good example is "ALT|CONTROL|F8". $OUTDIR is used for the working directory. You can change it by using SetOutPath before creating the Shortcut. description should be the description of the shortcut, or comment as it is called under XP. The error flag is set if the shortcut cannot be created (i.e. either of the paths (link or target) does not exist, or some other error).

CreateDirectory "$SMPROGRAMS\My Company"
CreateShortCut "$SMPROGRAMS\My Company\My Program.lnk" "$INSTDIR\My Program.exe" \
"some command line parameters" "$INSTDIR\My Program.exe" 2 SW_SHOWNORMAL \
ALT|CTRL|SHIFT|F5 "a description"
Angry Coder is offline   Reply With Quote
Old 12th May 2006, 02:08   #13
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
Ok, it worked when I did:

CreateShortCut "$SMSTARTUP\My Program.lnk" "$INSTDIR\My Program.exe" "hourglass.ico"

But how can I add the comment: "Do not delete this shortcut"?
Angry Coder is offline   Reply With Quote
Old 12th May 2006, 02:11   #14
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
And...

This is not working also:

Section "Uninstall"

Delete "$INSTDIR\Uninstall My Program.exe"
Delete "$INSTDIR\My Program.exe"
RMDir $INSTDIR
Delete "$SMSTARTUP\My Program.lnk" <------- Everything is ok, except this line. It doesn't remove the shortcut!

SectionEnd

Please help. Thanks.
Angry Coder is offline   Reply With Quote
Old 12th May 2006, 03:30   #15
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 853
Please, PLEEEEEESE do not double post. They are often ignored, or people will stop posting.

Shortcut description:
code:

CreateShortCut "$SMPROGRAMS\My Company\My Program.lnk" "$INSTDIR\My Program.exe" "" "hourglass.ico" "" "" "" "a description"


"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 12th May 2006, 04:44   #16
Angry Coder
Junior Member
 
Join Date: May 2006
Posts: 24
It worked

I'm really, Realllllly sorry
Angry Coder is offline   Reply With Quote
Old 24th June 2013, 06:28   #17
gbstack
Junior Member
 
Join Date: Jun 2013
Posts: 2
Actually you can add program path to registry "Run" key as well. If you add program to Start Menu/Startup folder, users can easily remove them by "Right Click->Delete". This post describes how to start program automatically in several ways, Also RunOnce key is an available option.
gbstack 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