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...!!!

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,346 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,083 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,203 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cheong00 3,471 Reputation points
    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.