windowsnsisarelle

NSIS RMDir failing to delete user created files in ProgramData


We have a Windows application with a component that writes to the ProgramData folder. When the uninstaller is run, the files that are generated by this component are not removed. Using UAC::RunElevated, we first install a third party component into ProgramData

SetOutPath "$RENDERER_INSTALL_DIR"

LogSet On
File /r "${MAGNIFY_DIR}/secRenderer/Arelle/*"
LogSet Off

AccessControl::GrantOnFile "$RENDERER_INSTALL_DIR" "(S-1-5-32-545)" "FullAccess"

During operation, this component writes to its own install directory in ProgramData

During uninstallation, we attempt to delete the folder created above, again using UAC::RunElevated

RMDir /r $RENDERER_INSTALL_DIR

However, the files created by operating the component are not removed.

We have observed that these files are owned by the user who used the component, rather than the Administrator, who nonetheless has full read, write and delete permissions.

How do we make this work?


Solution

  • There are two many unknowns here to really answer the question.

    Why is the UAC plug-in involved? It is only useful to lower your system access! It is also tricky to use correctly so I would recommend that you try without it.

    Does this 3rd-party component change the ACL? Check the ACL before uninstalling.

    Is it possible that file system virtualization is tricking you? Check the VirtualStore folder.

    What does Process Monitor say? Are you getting ACCESS_DENIED or some other error?

    Giving all users full access to folders under ProgramData is not recommended and any component that requires this does not follow the Windows Logo guidelines.