Pedro Oliveira
Pedro Oliveira

Reputation: 145

NSIS uninstaller doesn't delete files/folders

I'm writing a NSIS installer for one of the apps that the company I work for uses internally, the install process works fine, with no problems all the REG keys are created, and so are the files folders and services, that the App uses. For some reason I can't understand, the uninstall process doesn't work's.

The services created by the app are deleted and so are the Registry keys, the most simple part, the files themselves, I can't delete them through the uninstaller!

#Includes
!include "x64.nsh"
#Defines and Installer Properties
Outfile "ESTvnc Installer.exe"
Name ESTvnc 
Icon "${NSISDIR}\contrib\graphics\icons\VNCON.ico"
#Detect OS Version
Function .onInit
    StrCpy $instdir $PROGRAMFILES
    ${If} ${RunningX64}
        StrCpy $instdir $PROGRAMFILES32
    ${EndIf}
FunctionEnd

section
    SetShellVarContext all  
    CreateDirectory $instdir\EST\ESTvnc
    setOutPath $instdir\EST\ESTvnc
    File /r installfiles\*
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ESTvnc\" \
                 "DisplayName" "ESTvnc"
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ESTvnc"\
                 "UninstallString" "$instdir\EST\ESTvnc\uninstaller.exe"
    writeUninstaller $instdir\EST\ESTvnc\uninstaller.exe
    ExecWait '"$instdir\EST\estvnc\estvnc.exe" -install'
sectionEnd

section "Uninstall"
    SetShellVarContext all  
    SimpleSC::StopService "ESTVNC" 1 30
    pop $0
    SimpleSC::StopService "ESTVNCSR" 1 30
    pop $0
    SimpleSC::RemoveService "ESTVNC"
    SimpleSC::RemoveService "ESTVNCSR"    
    RMDir /r "$instdir\EST\ESTvnc"  
    Delete $instdir\EST\ESTvnc\uninstaller.exe  
    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ESTvnc"  
sectionEnd

Upvotes: 2

Views: 3808

Answers (1)

Anders
Anders

Reputation: 101606

In the uninstaller, $instdir is the directory the uninstaller is in!

Either place the uninstaller in $instdir and delete $instdir\EST\ESTvnc or if you want to keep it in $instdir\EST\ESTvnc, delete $instdir...

Upvotes: 5

Related Questions