Old 28th August 2014, 10:30   #1
Lilou1515
Junior Member
 
Join Date: Aug 2014
Posts: 2
script NSIS problème avec WriteRegStr

Bonjour.
J'ai créé un script NSIS pour que mon application se lance automatiquement à chaque ouverture de session Windows.

Cependant, lorsque j'ouvre une session, une ancienne version de mon application se lance et je ne comprends pas pourquoi.
J'ai pourtant recompilé mon script avec le nouvel exécutable de mon application.
Lorsque je lance mon application manuellement en cliquant sur le raccourci sur le bureau par exemple, c'est la bonne version de mon application qui se lance.

Merci d'avance pour votre aide.
Voici mon 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
Lilou1515 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > International Connection > International Connection

Tags
démarrer, hklm, logon, nsis, writeregstr

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump