![]() |
#1 |
Junior Member
Join Date: Aug 2014
Posts: 2
|
Problem with WriteRegStr (HKLM -> Run)
Hello.
I created a script to install my software on Windows. It should automatically start when a user logs on. The problem is that everytime I log on, a wrong version of my software automatically starts instead of the latest version. I don't understand why it does not work correctly because I compiled my script whith the latest version of my program and I can see in the installation directory that the latest version is installed. Thanks in advance for your help. Here is my script : ; Script generated by the HM NIS Edit Script Wizard. RequestExecutionLevel admin ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "app" !define PRODUCT_VERSION "1.0" !define PRODUCT_PUBLISHER "lol" !define PRODUCT_WEB_SITE "http://www.lol.fr" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\app.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" ; MUI 1.67 compatible ------ !include "MUI2.nsh" !include "FileFunc.nsh" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !define MUI_FINISHPAGE_RUN "$INSTDIR\app.exe" !define MUI_FINISHPAGE_RUN_NOTCHECKED !define MUI_FINISHPAGE_RUN_TEXT "Cochez pour démarrer app 1.0" !define MUI_FINISHPAGE_TEXT "ATTENTION : Veuillez copier vos fichiers de licence dans le répertoire d'installation." ;!define MUI_FINISHPAGE_TEXT_REBOOT "Veuillez redémarrer votre ordinateur pour terminer l'installation." !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "French" ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "Install.exe" InstallDir "$PROGRAMFILES\app" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show Function .onInit !insertmacro MUI_LANGDLL_DISPLAY ;Install Visual C++ runtime elements to be able to launch app Exec ".\vcredist_x86.exe" ;Remove comment to add auto restart at the end of the installation ;SetRebootFlag true FunctionEnd Section "SectionPrincipale" SEC01 SetOutPath "$INSTDIR" SetOverwrite ifnewer File ".\conf.ini" File ".\app.exe" CreateDirectory "$SMPROGRAMS\app" CreateShortCut "$SMPROGRAMS\app\app.lnk" "$INSTDIR\app.exe" CreateShortCut "$DESKTOP\app.lnk" "$INSTDIR\app.exe" SectionEnd Section -AdditionalIcons WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateShortCut "$SMPROGRAMS\app\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\app\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "app" "$INSTDIR\app.exe" ;app will be launch each time the user logs on WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run\" "app" "$INSTDIR\app.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\app.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "app a été désinstallé avec succès de votre ordinateur." FunctionEnd Function un.onInit !insertmacro MUI_UNGETLANGUAGE MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Êtes-vous certains de vouloir désinstaller totalement app et tous ses composants ?" IDYES +2 Abort FunctionEnd Section Uninstall Delete "$INSTDIR\${PRODUCT_NAME}.url" Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\*.xml" Delete "$SMPROGRAMS\app\Uninstall.lnk" Delete "$SMPROGRAMS\app\Website.lnk" Delete "$DESKTOP\app.lnk" Delete "$SMPROGRAMS\app\app.lnk" Delete "$INSTDIR\vcredist_x86.exe" RMDir "$SMPROGRAMS\app" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose true SectionEnd |
![]() |
![]() |
|
Tags |
hklm, logon, nsis, run, writeregstr |
Thread Tools | Search this Thread |
Display Modes | |
|
|