How to remove installation folder completly on msiexec.exe

Deepak Joy Joseph 1 Reputation point
2021-03-18T05:00:43.75+00:00

Hi All,
I am using this script to uninstall my product.

try { WshShell.Run("msiexec.exe /quiet /x {ProductCode}", 1, true); } catch(e) { }

The product is getting uninstalled but the root folder is not getting removed and it contains some file ( logs and all)

Is there any way to forcefully remove the entire folder even if it contains any folders or files.

Thanks in advance...!!!

Windows for business | Windows Server | User experience | Other
Developer technologies | .NET | Other
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. cheong00 3,486 Reputation points Volunteer Moderator
    2021-03-18T05:57:19.727+00:00

    You just "take ownership" of such folders and delete them afterwards.

    By default, Windows Installers will not remove non-empty folders, and it has no knowledge on folders that didn't be created by it, so you need to do that manually.

    If your MSI file is created with WiX Toolset, you can add RemoveFile / RemoveFolder / RemoveFolderEx element to tell Windows Installer to remove those files on uninstall.

    For other MSI file creation products, you'll need to read their manual to see if they offer similar options.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.