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!
Either launch install or launch app?
16 posts
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:
Hope this helps
-Duane
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:
The Reg key will replace the InstallDir with what the user has placed instead.InstallDirRegKey HKCU MyApp ""
InstallDir "$PROGRAMFILES\MyAPP\"
Hope this helps
-Duane
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.
Do something like this:
-Hendri.
To autorun, create a file "autorun.inf" containing 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
Good luck,[autorun]
open="path to app" ; replace!
icon="icon file" ; replace!
-Hendri.
Thanks
Thanks! Not having the code in an .onInit function is where I was messed up!
Thanks! Not having the code in an .onInit function is where I was messed up!
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.
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.
-Hendri.
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
Originally posted by rainwaterMlbl, that's the reason for the FileCheck!
If the user has deleted the file, then that method would fail to exec it.
-Hendri.
Originally posted by Smile2MeI don't see a filecheck in that function.
Mlbl, that's the reason for the FileCheck!
-Hendri.
Originally posted by Smile2MeIt needed to be added indeed, I just quoted you to show that the code needed some work, so:
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.
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
Wouldn't this be better:
I would think you would want the installer to run if the file is not there.
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
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.
-Hendri.
Originally posted by Smile2MeI'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?
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.
So indeed, we need a proper uninstall, but that was not he question 🙂
-Hendri.
-Hendri.
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.
-Hendri.