- NSIS Discussion
- Either launch install or launch app?
Archive: Either launch install or launch app?
Obra
17th July 2002 21:57 UTC
Either launch install or launch app?
I'd love to have my CDROM autoplay and then check the registry to see if my app is already installed.
It should then run the installer if not installed, or run the app if already installed.
Is this possible with NSIS? I've searched around but I'm starting to think this is not possible.
Any suggestions on how to accomplish this much appreciated!
DuaneJeffers
18th July 2002 08:45 UTC
Yes, this is very possible.
First, you should know how to autorun the app. If you don't, then I can tell you later.
Second, In the .nsi script type the following example, but replacing it with your appropriate coding:
InstallDirRegKey HKCU MyApp ""
InstallDir "$PROGRAMFILES\MyAPP\"
The Reg key will replace the InstallDir with what the user has placed instead.
Hope this helps
-Duane
Obra
18th July 2002 15:59 UTC
Thanks Duane. It's the "now that I know the app is installed, dont run the NSIS installer, but run the app instead" part that I can't seem to get to work. I do have the app launching after the install is complete just fine.
Smile2Me
18th July 2002 21:10 UTC
Do something like this:
InstallDir $PROGRAMFILES\MyApp
function .onInit
ReadRegStr $0 HKLM "Software\MyApp" "InstallPath"
StrCmp $0 "" Done
Exec "$0\MyApp.exe" it is installed! so run the program!
Quit
Done: ; So not installed? continue install then!
functionend
section
; some install stuff
sectionend
section ; do not forget to write the regkey
; to know next time that it is installed
WriteRegStr HKLM "Software\MyApp" "InstallPath" "$INSTDIR"
sectionend
To autorun, create a file "autorun.inf" containing this:
[autorun]
open="path to app" ; replace!
icon="icon file" ; replace!
Good luck,
-Hendri.
Obra
18th July 2002 21:52 UTC
Thanks
Thanks! Not having the code in an .onInit function is where I was messed up!
rainwater
19th July 2002 03:41 UTC
I would prefer checking the if the file exist (fileexist) instead of the registry. If the user has deleted the file, then that method would fail to exec it.
Smile2Me
19th July 2002 08:12 UTC
Yes, you need to perform a FileCheck before execution. But running from CD, we cannot do without the registry since we don't know where the app has been installed.
-Hendri.
mlbl
19th July 2002 12:58 UTC
Just wondering, can't you just check the registry key to see if it exists? If it doesn't, then the app wouldn't have been installed
Smile2Me
19th July 2002 13:11 UTC
Originally posted by rainwater
If the user has deleted the file, then that method would fail to exec it.
Mlbl, that's the reason for the FileCheck!
-Hendri.
rainwater
19th July 2002 15:13 UTC
Originally posted by Smile2Me
Mlbl, that's the reason for the FileCheck!
-Hendri.
I don't see a filecheck in that function.
Smile2Me
19th July 2002 15:31 UTC
Originally posted by Smile2Me
Yes, you need to perform a FileCheck before execution. But running from CD, we cannot do without the registry since we don't know where the app has been installed.
-Hendri.
It needed to be added indeed, I just quoted you to show that the code needed some work, so:
InstallDir $PROGRAMFILES\MyApp
function .onInit
ReadRegStr $0 HKLM "Software\MyApp" "InstallPath"
StrCmp $0 "" Done
IfFileExists "$0\myapp.exe" 0 errorquit
Exec "$0\MyApp.exe" ; it is installed! so run the program!
Quit
ErrorQuit:
MessageBox MB_OK "You stupid man! You deleted the program! ERROR!"
Quit
Done: ; So not installed? continue install then!
functionend
section
; some install stuff
sectionend
section ; do not forget to write the regkey
; to know next time that it is installed
WriteRegStr HKLM "Software\MyApp" "InstallPath" "$INSTDIR"
sectionend
rainwater
19th July 2002 15:43 UTC
Wouldn't this be better:
InstallDir $PROGRAMFILES\MyApp
function .onInit
ReadRegStr $0 HKLM "Software\MyApp" "InstallPath"
StrCmp $0 "" Done
IfFileExists "$0\myapp.exe" 0 Done
Exec "$0\MyApp.exe" ; it is installed! so run the program!
Quit
Done: ; So not installed? continue install then!
functionend
section
; some install stuff
sectionend
section ; do not forget to write the regkey
; to know next time that it is installed
WriteRegStr HKLM "Software\MyApp" "InstallPath" "$INSTDIR"
sectionend
I would think you would want the installer to run if the file is not there.
Smile2Me
19th July 2002 17:33 UTC
My solution is intended to run the program on harddisk if installed. Otherwise the installation will continue. So no aditional installation needed that should be run. My solution prouces a small exe can be put on CD, autorun and work as installer or as program starter.
-Hendri.
rainwater
19th July 2002 18:19 UTC
Originally posted by Smile2Me
My solution is intended to run the program on harddisk if installed. Otherwise the installation will continue. So no aditional installation needed that should be run. My solution prouces a small exe can be put on CD, autorun and work as installer or as program starter.
-Hendri.
I'm not sure I understand. If the user's registry key doesnt get deleted when the program was removed, your solution would fail to install the application. Correct?
Smile2Me
19th July 2002 19:07 UTC
So indeed, we need a proper uninstall, but that was not he question :)
-Hendri.
Smile2Me
20th July 2002 07:43 UTC
A solution to the problem that people delete applications instead of uninstalling them could be this: if no regkey -> just install. If the regkey is present -> present an InstOpts dialog asking to "reinstall" or "run" (and maybe even "uninstall") and where run is default. This way this problem would have been solved.
-Hendri.