Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: Removing files and registry entities created after installation

$
0
0
You can actually use RemoveFolderEx as any of other WiX extension (XML injection will be required). But... I am also for more elegant solution and for me nothing bits teh elegancy of fully featured C# code :)
project.AfterInstall += project_AfterInstall;
...
staticvoid project_AfterInstall(SetupEventArgs e)
{
    if (e.IsUninstalling)
    {
        var logFiles = Directory.GetFiles(e.InstallDir, "*.log", SearchOption.AllDirectories);
        foreach (var item in logFiles)
            IO.File.Delete(item);

        if(e.Data["UPGRADINGPRODUCTCODE"].IsEmpty()) //only set if triggered by upgrade
            Registry.CurrentUser.DeleteSubKeyTree("<key path>");
    }
}
You will need just add error handling and that is it. Note that AfterInstall runs elevated so there will be no problems with the read-write access.

Viewing all articles
Browse latest Browse all 1354

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>