Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:48:16+00:00 2026-06-15T18:48:16+00:00

Previous installation of my product was done in Visual Studio 2008 as deployment project

  • 0

Previous installation of my product was done in Visual Studio 2008 as deployment project (vdproj). User had the option to install per user (just me) or per machine (everyone). I’m doing new installation in WiX, and if product was installed per machine then new installation will uninstall previous version. BUT, if product was installed per user in %ProgramFiles% then new installation will not uninstall previous, making a mess of two installations in the same folder.

I want to detect and stop the installation in this situation. No automatic uninstall, just detect and stop. The solution should handle the case if one user did previous per user installation, and another user is doing new per machine. I thought DirectorySearch and FileSearch elements could be used, but they run before target folder is determined in UI.

If WiX code is involved please provide small example. I’ll learn from it.

EDIT: If I add a property using AppSearch features DirectorySearch and FileSearch, and then check a condition with Condition element this would check the condition at installation startup. This is not what I want. The user may change the target folder, so I need to check the existence of files in target folder in some step after the target folder can no longer be changed.

In my naivety I also tried to read the value of property mentioned in previous paragraph with SetProperty in some custom action, but that does not work either. The value is read alright, but it’s the value that was determined at the start of setup.

Proper solution should probably include the answer given to another question. I’m currently toying with JScript, as per tip given in WiX tricks community wiki. Will probably make it a .dll to avoid anti-virus meddling, mentioned in Rob Mensching’s blog post.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:48:17+00:00Added an answer on June 15, 2026 at 6:48 pm

    Here’s how I’ve done it in the end. I’m calling custom action queued after RemoveExistingProducts:

    <Property Id='ERRORIFFILESFOUND_MESSAGE'>!(loc.OlderVersionNotRemoved)</Property>
    
    <CustomAction Id="CA.ErrorIfFilesFound"
      BinaryKey="SetupSupport.dll" DllEntry="ErrorIfFilesFound"
      Execute="immediate" Return="check" />
    
    <CustomAction Id='CA.ErrorIfFilesFound.SetDirectory' 
      Property='ERRORIFFILESFOUND_DIRECTORY' Value='[INSTALLDIR]' />
    
    <InstallExecuteSequence>
      <Custom Action='CA.ErrorIfFilesFound.SetDirectory' After='RemoveExistingProducts' />
      <Custom Action='CA.ErrorIfFilesFound' After='CA.ErrorIfFilesFound.SetDirectory'>
        Not MAJORUPGRADEPROPERTY and Not Installed
      </Custom>
    </InstallExecuteSequence>
    

    After this point old installation is removed if possible, so if there are files remaining in target folder then something’s wrong. This moment happens rather late, but I don’t know of a way to detect if existing files are going to be uninstalled. Code in custom action just checks if target folder exists and is not empty, and if so calls it quits (ExitOnFailure error handling removed for brevity):

    UINT WINAPI ErrorIfFilesFound(MSIHANDLE hInstall)
    {
        HRESULT hr = S_OK;
        LPWSTR pwszDirectory = NULL;
        LPWSTR pwszMessage = NULL;
    
        hr = ::WcaInitialize(hInstall, "ErrorIfFindFile");
    
        hr = ::WcaGetProperty(L"ERRORIFFILESFOUND_DIRECTORY", &pwszDirectory);
    
        if (PathIsDirectory(pwszDirectory) && !PathIsDirectoryEmpty(pwszDirectory))
        {
            hr = ::WcaGetProperty(L"ERRORIFFILESFOUND_MESSAGE", &pwszMessage);
    
            ProcessInstallMessage(hInstall,
                INSTALLMESSAGE_ERROR, pwszMessage, pwszDirectory);
    
            hr = -1;
        }
    
    LExit:
        ReleaseStr(pwszMessage);
        ReleaseStr(pwszDirectory);
    
        UINT err = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
        return ::WcaFinalize(err);
    }
    
    void ProcessInstallMessage(MSIHANDLE hInstall,
        INSTALLMESSAGE type, TCHAR* lpszMessage, TCHAR* lpszParam)
    {
        UINT rc;
        MSIHANDLE hMsg;
        UINT uiFieldNumber = lpszParam == NULL ? 0 : 1;
    
        hMsg = MsiCreateRecord(uiFieldNumber);
    
        if (hMsg != 0)
        {
            if ((rc = MsiRecordSetString(hMsg, 0, lpszMessage)) != ERROR_SUCCESS)
            {}
            else if (lpszParam != NULL &&
                (rc = MsiRecordSetString(hMsg, 1, lpszParam)) != ERROR_SUCCESS)
            {}
            else
            {
                rc = MsiProcessMessage(hInstall, type, hMsg);
            }
    
            rc = MsiCloseHandle(hMsg);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember that in previous installations of Visual Studio that I had, when I
I am trying to delete an old user from our perforce installation. A previous
Using Visual Studio setup project. I'd like to change Everyone / Just Me choice
I have done my best to install a copy of SQL Server 2008, but
i'm going to install sql server 2008 on my computer,during preparing the installation there
I want to build a navigation screen, just like installation shields has (next/previous stuff),
I previous recieved help with a problem, getting a multiple option select form to
From previous experience I had been under the impression that it's perfectly legal (though
In previous question of mine, someone had meantioned that using Semaphores were expensive in
When I try to install over a previous version I get the error The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.