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'
Launch a program by accessing it's link from STARTUP
17 posts
NSIS already has a $SMSTARTUP constant (see docs!)
-Stu
-Stu
I already tried that but it didn't work.
Try the commands Exec or ExecShell instead of the nsExec Plugin
Yes you need to use ExecShell
Exec is for exe files.
nsExec::Exec is for command-line applications (mostly).
-Stu
Exec is for exe files.
nsExec::Exec is for command-line applications (mostly).
-Stu
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 ?
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 ?
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"
- ExecShell "open" "Path\to\Textfile"
- Exec "Notepad.exe" "Path\to\Textfile"
I've not made the shortcut within my installer. The shortcut exists on the user's computer. Any ideas now?
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
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
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.
ExecShell "" '$SMSTARTUP\merge.lnk' and ExecShell "open" '$SMSTARTUP\merge.lnk'
It still doesn't anything. I'm very confused.
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"
Perhaps you should ensure that you point to the correct location using the command "IfFileExists"
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.
I tested it now and for me it works.
In my test it worked with ExecShell open and ExecShell ""
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
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.
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.
What Specs you have?
I tested it under WINDOWS XP Pro SP1 with NSIS 2.05
I tested it under WINDOWS XP Pro SP1 with NSIS 2.05
Last NSIS Menu.lnk code also works fine on Win2K Server SP2, NSIS 2.04.
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.