- NSIS Discussion
- Launch a program by accessing it's link from STARTUP
Archive: Launch a program by accessing it's link from STARTUP
Chilli24
9th February 2005 10:41 UTC
Launch a program by accessing it's link from STARTUP
I want to launch a program by accessing it's link from STARTUP. I have tried this code, but it doesn' work. Anybody now what's the solution?
ClearErrors
ReadRegStr $startup HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Startup"
nsExec::Exec '$startup\launchthis.lnk'
Afrow UK
9th February 2005 10:52 UTC
NSIS already has a $SMSTARTUP constant (see docs!)
-Stu
Chilli24
9th February 2005 11:51 UTC
I already tried that but it didn't work.
flizebogen
9th February 2005 12:58 UTC
Try the commands Exec or ExecShell instead of the nsExec Plugin
Afrow UK
9th February 2005 13:21 UTC
Yes you need to use ExecShell
Exec is for exe files.
nsExec::Exec is for command-line applications (mostly).
-Stu
Chilli24
9th February 2005 13:31 UTC
OK. I tried this:
ExecShell "open" '$SMSTARTUP\merge.lnk'
And it didn't work.
What's the scenario: I have a text document named merge.txt that has a shortcut into the STARTUP folder. How do I execute that shortcut ?
flizebogen
9th February 2005 13:35 UTC
If you made the shortcut within your installer why would you execute the shortcut to open a text file? There a different ways to open it. Try one of these:
- ExecShell "open" "Path\to\Textfile"
- Exec "Notepad.exe" "Path\to\Textfile"
Chilli24
9th February 2005 14:08 UTC
I've not made the shortcut within my installer. The shortcut exists on the user's computer. Any ideas now?
flizebogen
9th February 2005 14:47 UTC
perhaps this helps:
SetShellVarContext All/current
; you should set the above to the correct value. If not it can happen that it starts in the wrong location
ExecShell "" '$SMSTARTUP\merge.lnk'
; if open is not the default action
Chilli24
10th February 2005 09:10 UTC
I've tried both SetShellVarContext current and SetShellVarContext All with
ExecShell "" '$SMSTARTUP\merge.lnk' and ExecShell "open" '$SMSTARTUP\merge.lnk'
It still doesn't anything. I'm very confused.
flizebogen
10th February 2005 09:33 UTC
The question is does your open command point to the correct location or has nsis a problem to start link files.
Perhaps you should ensure that you point to the correct location using the command "IfFileExists"
Chilli24
10th February 2005 09:39 UTC
The $SMSTARTUP points to the right location because I've read the path to Startup directly from the registry and it's the same as $SMSTARTUP. So this is not the problem.
flizebogen
10th February 2005 09:58 UTC
I tested it now and for me it works.
OutFile "test.exe"
Section ""
SetShellVarContext current
IfFileExists "$SMPROGRAMS\7-Zip\7-Zip File Manager.lnk" file_exists
MessageBox MB_OK "File not found"
Goto Ende
file_exists:
ExecShell "open" "$SMPROGRAMS\7-Zip\7-Zip File Manager.lnk"
ende:
SectionEnd
In my test it worked with ExecShell open and ExecShell ""
Chilli24
10th February 2005 10:34 UTC
OK. I've tried this and it doesn't work.
SetShellVarContext current
IfFileExists "$SMPROGRAMS\NSIS\NSIS Menu.lnk" file_exists
MessageBox MB_OK "File not found"
Goto Ende
file_exists:
ExecShell "open" "$SMPROGRAMS\NSIS\NSIS Menu.lnk"
ende:
I've also tried:
ExecShell "" "$SMPROGRAMS\NSIS\NSIS Menu.lnk"
It doesn't say that the file does not exist but it doesn't do anything.
flizebogen
10th February 2005 10:44 UTC
What Specs you have?
I tested it under WINDOWS XP Pro SP1 with NSIS 2.05
Takhir
10th February 2005 10:54 UTC
Last NSIS Menu.lnk code also works fine on Win2K Server SP2, NSIS 2.04.
Chilli24
10th February 2005 12:17 UTC
On XP SP2 it didn't work. On 2000 server it works. I'll have to see it works on 2003 server too. Everybody, thanks for your help.