Computerhilfen.de Logo
Forum
Tipps
News
Frage stellen

NSiS Frage zwecks installationsscript

Guten Morgen,

eine Frage ist es möglich bei NSIS zu prüfen vor der eigentlichen Installations ob das Installdir bereits vorhanden ist und das dann ggf löschen?

haben schon   # IfFileExists "$INSTDIR\*" 0 NoFile
ausprobiert aber irgendwie ignoriert er mir die abfrage

kann mir wer hier weiterhelfen?


Antworten zu NSiS Frage zwecks installationsscript:

Hier ist der quellcode dazu natürlich habe ich relevante namen abgeändert also nicht wundern.

Zitat
# Defines
!define REGKEY "SOFTWARE\$(^Name)"
# Set version and source directory to default values if not defined on the command line with /D
!ifndef VERSION
!define VERSION DEVELOPMENT
!endif
!ifndef SOURCEDIR
#!define SOURCEDIR C:\tempXavo\XBClient\eclipse
!define SOURCEDIR "C:\tempXavo\sctemp\eclipse"
!endif
!define COMPANY "link"

# MUI defines
!define MUI_ICON icons\verk.ico
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
!define MUI_STARTMENUPAGE_DEFAULTFOLDER Xavo
!define MUI_FINISHPAGE_RUN "$INSTDIR\start.exe"
!define MUI_FINISHPAGE_RUN_PARAMETERS -clean
!define MUI_CUSTOMFUNCTION_GUIINIT CustomGUIInit
!define MUI_UNICON icons\start2.ico
!define MUI_UNFINISHPAGE_NOAUTOCLOSE

# Included files
!include Sections.nsh
!include MUI.nsh

# Reserved Files
ReserveFile "${NSISDIR}\Plugins\BGImage.dll"
ReserveFile "${NSISDIR}\Plugins\AdvSplash.dll"

# Variables
Var StartMenuGroup

# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Installer languages
!insertmacro MUI_LANGUAGE English

# Installer attributes
OutFile setup.exe
InstallDir "$PROGRAMFILES\xyz"
CRCCheck on
XPStyle on
ShowInstDetails show
VIProductVersion 0.0.0.0
VIAddVersionKey ProductName "start"
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey CompanyWebsite "${URL}"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey FileDescription ""
VIAddVersionKey LegalCopyright ""
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails show

# Installer sections
Section -Main SEC0000
    SetOutPath $INSTDIR
    SetOverwrite on
    File /r "${SOURCEDIR}\*"
    WriteRegStr HKLM "${REGKEY}\Components" Main 1
SectionEnd

Section -post SEC0001
    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
    SetOutPath $INSTDIR
    WriteUninstaller $INSTDIR\uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    SetOutPath $SMPROGRAMS\$StartMenuGroup
    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\startt.lnk" "$INSTDIR\start.exe"
    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall start.lnk" $INSTDIR\uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_END
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
SectionEnd

Den deinstaller lass ich mal weg sonst wäre der code noch länger

und nun die functions:
Zitat

# Installer functions
Function CustomGUIInit
    Push $R1
    Push $R2
    BgImage::SetReturn /NOUNLOAD on
    BgImage::SetBg /NOUNLOAD /GRADIENT 255 255 255 255 255 255
    Pop $R1
    Strcmp $R1 success 0 error
    File /oname=$PLUGINSDIR\bgimage.bmp installer-background.bmp
    System::call "user32::GetSystemMetrics(i 0)i.R1"
    System::call "user32::GetSystemMetrics(i 1)i.R2"
    IntOp $R1 $R1 - 500
    IntOp $R1 $R1 / 2
    IntOp $R2 $R2 - 900
    IntOp $R2 $R2 / 2
    IntCmp $R2 0 lessorequal lessorequal morethan
lessorequal:
    IntOp $R2 0 + 0
morethan:
    BGImage::AddImage /NOUNLOAD $PLUGINSDIR\bgimage.bmp $R1 $R2
#    CreateFont $R1 "Times New Roman" 26 700 /ITALIC
#    BGImage::AddText /NOUNLOAD "$(^SetupCaption)" $R1 255 255 255 16 8 500 100
    Pop $R1
    Strcmp $R1 success 0 error
    BGImage::Redraw /NOUNLOAD
    Goto done
error:
    MessageBox MB_OK|MB_ICONSTOP $R1
done:
    Pop $R2
    Pop $R1
FunctionEnd

Function .onGUIEnd
    BGImage::Destroy
FunctionEnd

Function .onInit
    InitPluginsDir
    Push $R1
    File /oname=$PLUGINSDIR\spltmp.bmp splash.bmp
    advsplash::show 1000 600 400 -1 $PLUGINSDIR\spltmp
    Pop $R1
    Pop $R1
FunctionEnd

« Apache serverVB6 - Passwortsystem »
 

Schnelle Hilfe: Hier nach ähnlichen Fragen und passenden Tipps suchen!

Fremdwörter? Erklärungen im Lexikon!
Set Top Box
Als Set-top-Box, englisch für Draufstellkasten oder Beistellgerät, wird ein Spezialisierter Grafik- und Kommunikationscomputer bezeichnet, den man an den Fernse...

Beta Version
Unter einer Beta Version versteht man ein Programm, das sich in einer Testphase, also noch vor der finalen Version, die veröffentlicht wird, befindet. Allgemein wird...

Bulk Version
Eine Bulk-Version ist nicht für den Einzelverkauf gedacht, sondern für Händler, die daraus ein Komplettangebot zusammenstellen. Oft erhält man nur die...