0

I'm developing a VSTO add-in for Microsoft Word and packaging it using a .msi installer (Visual Studio Installer Project). Before proceeding with the installation, I want to ensure that Word (winword.exe) is not running. If it is, I’d like to block the installation with a user-friendly message like:

"Please close Microsoft Word before installing StyleGuard Pro."

What I've tried:

✅ Custom Action DLL: Tried adding a custom action in the Installer project to check for running processes using Process.GetProcessesByName("WINWORD"), but that results in Error 1001 or similar issues during installation.

throw new InstallException("Microsoft Word is currently running.\n\nPlease close Word and run the installer again.");

✅ Tried running the check in Install, Commit, and InstallUI phases — but still unreliable or unstable, especially in silent installations or under limited permissions.

❌ Launch Conditions don’t support checking running processes — only registry, file system, or Windows Installer properties.

❌ MSI dialogs like MsiRMFilesInUse can list Word as in-use, but don’t give me control to block the install programmatically.

My current workaround:

I created a WPF-based bootstrapper .exe that:

  1. Checks for running winword.exe
  2. If running, shows a MessageBox to prompt the user to close it
  3. Only then extracts and runs the embedded .msi using msiexec

This works fine — but it adds complexity, an extra build step, and now I’m shipping two files (exe + msi).

My Question: 👉 Is it possible to check if Word is running directly inside a .msi installation without causing Error 1001 or installer failure?

  1. Can I detect winword.exe cleanly within a pure .msi (no bootstrapper)?
  2. Can this be done reliably using any deferred, immediate, or UI custom actions?
  3. Are there better patterns or supported ways of handling this in Visual Studio Installer Projects or WiX?
  4. Or is a bootstrapper .exe the only safe and reliable way to block installation if Word is open?

Any suggestions, best practices, or real-world guidance would be appreciated.

1
  • 1
    Why do you want to close Word? VSTO can be installed while Word is running; it will be available on the next launch. Commented Jun 26 at 17:47

1 Answer 1

0

You can use wix built-in function called CloseApplication, it was designed to address that exactly scenario: https://docs.firegiant.com/wix/schema/util/closeapplication/

<util:CloseApplication 
  Id="CloseApp" 
  PromptToContinue="yes" 
  Description="The setup wants to close Word."
  CloseMessage="yes" 
  Target="Word.exe" 
  RebootPrompt="no" 
/>

BTW, I really don't think you need to close Word (like I've stated in the comment), if you get an error during installation it may be something else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.