Announcement

Collapse
No announcement yet.

RMDir not deleting root install folder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RMDir not deleting root install folder

    I've just recompiled the installer code using NSIS 2.07 instead of 2.05 but for some reason the uninstaller doesn't allow deleting the root install folder.

    I don't recall having this error in NSIS 2.05.

    I'm using the below code to delete the install folders:

    ;**************************************************************************************************
    ;Delete files created upon installation
    ;**************************************************************************************************

    ;Delete "$INSTDIR\Icons\*.*"
    ;Delete "$INSTDIR\Help\*.*"
    ;Delete "$INSTDIR\*.*"

    ;**************************************************************************************************
    ;Delete folders created upon installation
    ;**************************************************************************************************
    RMDir /r "$INSTDIR"


    Also in the script I have:

    **************************************************************************************************
    ;Installer default installation folder
    ;**************************************************************************************************
    InstallDir "$PROGRAMFILES\xxx.yyy\zzz www 2006"

    What's going wrong? All sub-folders get deleted just not the root install folder.

    Thanks.

  • #2
    Windows not deletes application's current folder, so you should remove /SetOutPath $INSTALLDIR/ if this presents and not required in uninstaller (full paths in most cases) or change it before RMDir /SetOutPath ../.

    Comment


    • #3
      Originally posted by Takhir
      Windows not deletes application's current folder, so you should remove /SetOutPath $INSTALLDIR/ if this presents and not required in uninstaller (full paths in most cases) or change it before RMDir /SetOutPath ../.
      Hmmm

      I haven't changed any code (just names of files/folders) since when I compiled it with NSIS 2.05 so why suddenly does one need to take a different approach?

      I don't have SetOutPath $INSTALLDIR in my uninstaller section.

      I'm thinking it must be something to do with InstallDir being a two level folder (i.e. xxx\yyy). In such case it's deleting the sub folder (yyy) but not the root folder (xxx).

      Comment


      • #4
        Any other ideas anyone?

        Comment


        • #5
          NSIS Documentation:
          Note that the current working directory can not be deleted. The current working directory is set by SetOutPath.
          Why you use (RMDir /r "$INSTDIR")? Try this:
          code:
          SetOutPath "$TEMP"
          Delete "$INSTDIR\Icons\*.*"
          Delete "$INSTDIR\Help\*.*"
          Delete "$INSTDIR\*.*"
          RMDir "$INSTDIR"

          or
          code:
          SetOutPath "$TEMP"
          RMDir /r "$INSTDIR"

          Last edited by Instructor; 4 July 2005, 17:07.
          my functions

          Comment


          • #6
            I changed it to what's below in the uninstaller sectio but the root installation folder still exists after I've run the uinstaller.

            It's content gets deleted, just not the root folder hence it's always left empty.

            SetOutPath "$TEMP"
            RMDir /r "$INSTDIR"

            This is confusing, I could swear it worked fine with NSIS 2.05

            Comment


            • #7
              Try Sleep 1000 before it.

              -Stu

              Comment


              • #8
                Originally posted by Afrow UK
                Try Sleep 1000 before it.

                -Stu
                Put in the sleep and no change.

                I'm beginning to scratch out the remaining hair I have

                I don't get it because neither is it a protected folder or a hidden or a system one.

                Below is my uninstall code, all works except the root folder delete:

                *******************

                ;--------------------------------
                ;UNINSTALLER SECTIONS #############################################################################


                ;/////////////////////////////////////////////////////////
                Section "Uninstall"
                ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

                ;**************************************************************************************************
                ;Delete files created upon installation
                ;**************************************************************************************************

                ;Delete "$INSTDIR\Icons\*.*"
                ;Delete "$INSTDIR\Help\*.*"
                ;Delete "$INSTDIR\*.*"

                ;**************************************************************************************************
                ;Delete folders created upon installation
                ;**************************************************************************************************

                Sleep 1000
                SetOutPath "$TEMP"
                RMDir /r "$INSTDIR"

                ;**************************************************************************************************
                ;Delete Start Menu links
                ;**************************************************************************************************

                !insertmacro MUI_STARTMENU_GETFOLDER Application $R0

                Delete "$SMPROGRAMS\$R0\${STARTMENU_LINK_APP_NAME}.lnk"
                Delete "$SMPROGRAMS\$R0\${STARTMENU_LINK_APP_UNINSTALL}.lnk"
                Delete "$SMPROGRAMS\$R0\${STARTMENU_LINK_APP_HELP}.lnk"

                Delete "$QUICKLAUNCH\${STARTMENU_LINK_APP_NAME}.lnk"

                ;Delete empty start menu parent diretories
                StrCpy $R0 "$SMPROGRAMS\$R0"

                RMDir $R0

                ClearErrors

                ;**************************************************************************************************
                ;Delete created registry keys
                ;**************************************************************************************************
                DeleteRegKey HKLM "Software\xxx.yyy"
                DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xxx.yyy zzz www 2006"
                DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "yyy www 2006"

                SectionEnd

                ;/////////////////////////////////////////////////////////
                Section "-un.Uninstall VB6 runtimes"
                ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

                !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll"
                !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll"
                !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll"
                !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat32.dll"
                !insertmacro UnInstallLib DLL SHARED NOREMOVE "$SYSDIR\asycfilt.dll"
                !insertmacro UnInstallLib TLB SHARED NOREMOVE "$SYSDIR\stdole2.tlb"

                SectionEnd

                Comment


                • #9
                  No hidden files in it?
                  What about after a reboot with /rebootok?

                  -Stu

                  Comment


                  • #10
                    Originally posted by Afrow UK
                    No hidden files in it?
                    What about after a reboot with /rebootok?

                    -Stu
                    You suggesting I force users to reboot after uninstallation? NSIS 2.05 worked fine.

                    I'm going to checkt this now but I don't think it can be anything to do with the "." in the folder name.

                    Comment


                    • #11
                      I've also specified the install DIR as a three stage folder as below, but this is normal right?

                      InstallDir "$PROGRAMFILES\xxx.yyy\zzz www 2006"

                      Comment


                      • #12
                        Well it's not the "." in the folder name that's for sure, just checked!

                        Comment


                        • #13
                          I think you'll need a RMDirUp function that recursively removes any empty parent folders.

                          I'll try to write one up and post it. I have this same issue.

                          Comment


                          • #14
                            RMDir /r should do that. I just tried it and had no problems (2.07).

                            Edit: No I'm not saying you must get the user to restart after uninstall. I'm asking you if it works after a reboot.

                            -Stu

                            Comment


                            • #15
                              Neither "RMDir /r $INSTDIR" or "RMDir /r /REBOOTOK $INSTDIR" remove the empty parent directories for me, before OR after a reboot.

                              This is what I came up with and works fine:
                              code:

                              Function un.RMDirUP
                              !define RMDirUP '!insertmacro RMDirUPCall'

                              !macro RMDirUPCall _PATH
                              push '${_PATH}'
                              Call un.RMDirUP
                              !macroend

                              ; $0 - current folder
                              ClearErrors

                              Exch $0
                              ;DetailPrint "ASDF - $0\.."
                              RMDir "$0\.."

                              IfErrors Skip
                              ${RMDirUP} "$0\.."
                              Skip:

                              Pop $0

                              FunctionEnd

                              Use:
                              code:

                              RMDir /r "$INSTDIR"
                              ${RMDirUP} "$INSTDIR"

                              Comment

                              Working...
                              X