No announcement yet.

Delete command not deleting files in Windows directories

  • Filter
  • Time
  • Show
Clear All
new posts

  • Delete command not deleting files in Windows directories

    I am having a problem where my uninstaller is not deleting files properly from Windows folders.

    The commands are (I've put some placeholders in for confidentiality):
    Delete $WINDIR\system32\[filename].dll
    Delete $WINDIR\sysWOW64\[filename].dll
    Delete $WINDIR\system32\drivers\[filename].sys

    My current suspicion is that the DLL files are in use by a different driver not just mine, since they are API DLLs. The sys file is only for my driver, however, and I know the driver is being removed from Windows. It doesn't get deleted either. However, the uninstaller gives no error when it tries to delete the files.

    I am going to run the installer and uninstaller on a clean boot machine to see if I get different behavior. I was hoping however that someone would have ideas to make the files delete properly

  • #2
    Make sure you have the RequestExecutionLevel attribute in your script.

    Are you using the macros in x64.nsh to disable redirection?

    Monitor the uninstaller with Process Monitor to see why the delete fails.
    IntOp $PostCount $PostCount + 1


    • #3
      I have the RequestExecutionLevel attribute at the beginning of the script. I also tried adding it to the uninstall portion of the script, but that gave an error. The only macro I am using currently is the InstallLib DLL to install the 64 bit API dll into the system32 folder. On my clean boot PC, the file in syswow64 is deleted properly, but the other two files are not deleted.


      • #4
        And what does Process Monitor say?

        And it is hard to say what is going on without any code.

        Should probably look something like this:
        ${If} ${RunningX64}
        !define LIBRARY_X64 ; Will call ${DisableX64FSRedirection} internally
        !insertmacro UnInstallLib ... ; Uninstall 64-bit module from system32 on 64-bit Windows
        !insertmacro UnInstallLib ... ; Uninstall 32-bit module from system32 (32-bit Windows) or syswow64 (64-bit Windows)
        IntOp $PostCount $PostCount + 1


        • #5
          Process Monitor shows that Windows is indeed redirecting. I can see where the first file is deleted, and it tries to delete the other two files, but in the wrong place. I will try using the UnInstallLib macro instead of the simple Delete command.


          • #6
            You can use Delete if the .dll is not registered but you have to use the macros in x64.nsh to deal with the redirection.
            IntOp $PostCount $PostCount + 1