0
votes

I am having issues deleting files and folders. 3 days to solve this. Today i spend 6 hours and still not find the solution. I am trying to make a simple installer/uninstaller with NSIS without using any variables, macros or complicated stuffs. My uninstaller is only able to delete the desktop shortcuts.

Solutions i tried:

  • searched stackoverflow for posts
  • tried with /REBOOTOK , delete, RmDir.
  • i checkd 5 times the paths on my PC (windows 10) and i think the paths are correct.

this is my nsi script:

# Nombre del instalador. Aparece en la barra superior al lanzar el instalador.
Name "Cliente de Correo - Stephane"

# El nombre del instalador
OutFile "ClienteCorreoStephane.exe"

# Configuramos la ruta por defecto donde se instala. Se puede usar $DESKTOP para
#el escritorio
InstallDir $PROGRAMFILES\ClienteCorreoStephane

# Pedimos permisos para Windows. se puede usar "user" pero
#lo normal es usar "admin" para tener todos los permisos
RequestExecutionLevel admin

# Pantallas que hay que mostrar del instalador
# te saca una ventana preguntando en que directorio quieres instalar
# Si pones páginas, hay que poner esas 2 como mínimo. Existen más paginas.
Page directory
Page instfiles

#Cambiar el idioma
!include "MUI.nsh"
!insertmacro MUI_LANGUAGE "Spanish"


#Seccion principal
Section

# muestra una ventanita con un texto y un botón que pone "Hola Mundo" y
# un botón de "ok". El instalador no continúa hasta que pulses el botón.
messageBox MB_OK "Gracias por instalar el cliente de correos de Stephane"

# Establecemos la ruta de instalacion al directorio de instalacion
SetOutPath $INSTDIR\files

# Creamos el desinstalador
writeUninstaller "$INSTDIR\files\uninstall.exe"

# anadimos a nuestro paquete instalador los siguientes archivos
File /r ".\clienteCorreoDefinitivo_jar\*" #aqui anade todo mi proyecto
File /r "..\..\ayuda" #anade la carpeta ayuda que esta fuera del src
File /r "..\..\informes" #anade la carpeta informes que esta fuera del src
File /r "..\..\recursos" #anade la carpeta informes que esta fuera del src

# anadiremos nuestro JavaFX y JRE. Para eso cambiaremos el setoutpath. Recordar cambiar
# el nombre de las carpetas del setoutpath.
# aquí anadimos nuestro javaFX
SetOutPath $INSTDIR\files\javafx13 #Este nos crea una carpeta javafx13 y nos mete todo lo siguiente dentro
File /r "C:\Program Files\Java\javafx13\*"
# aquí anadimos nuestr JRE
SetOutPath $INSTDIR\files\java-runtime #Este nos crea una carpeta java-runtime y nos mete todo lo siguiente dentro
File /r "C:\Program Files\Java\jdk-13\bin\java-runtime\*"


#Añadimos información para que salga en el menú de desinstalar de Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane" \
             "DisplayName" "ClienteCorreoStephane"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane" \
             "Publisher" "Stephane - Desarrollo Interfaces"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane" \
             "UninstallString" "$\"$INSTDIR\uninstall.exe$\""

# Creamos un acceso directo apuntando al desinstalador
createShortCut "$SMPROGRAMS\Desinstalar.lnk" "$INSTDIR\files\uninstall.exe"
createShortCut "$DESKTOP\Desinstalar.lnk" "$INSTDIR\files\uninstall.exe"
createShortCut "$DESKTOP\ClienteCorreoStephane.lnk" "$INSTDIR\files\java-runtime\bin\java.exe --module-path ..\..\javafx13\lib --add-modules javafx.controls,javafx.fxml,javafx.graphics,javafx.web,javafx.base --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED -jar ..\..\clienteCorreoDefinitivo.jar" "$INSTDIR\files\recursos\mierda_icon.ico"

SetOutPath $INSTDIR
# Fin de la seccion
SectionEnd

# seccion del desintalador. Siempre se llamará uninstall
section "uninstall"

# borramos el desintalador primero. No pasa nada, seguirá funcionando
# aunque se disinstale a si mismo.
#delete "$INSTDIR\files\uninstall.exe"

# borramos el directorio files
#RmDir /r /REBOOTOK "$INSTDIR\files"
RmDir /r "$INSTDIR\files"

# borramos el directorio general. si quedan archivos dentro, no lo borrará
RmDir /REBOOTOK "$INSTDIR"

# Borramos la entrada del registro
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane"

# borramos el acceso directo del menu de inicio
delete "$SMPROGRAMS\Desinstalar.lnk"
delete "$DESKTOP\Desinstalar.lnk"
delete "$DESKTOP\ClienteCorreoStephane.lnk"

# fin de la seccion del desinstalador
sectionEnd

I also had issues loading my jar file with the desktop shortcut. How do I solve this too?

1

1 Answers

0
votes

$Instdir in the uninstaller is the folder the uninstall .exe file is in, not the value it had in the installer.