Archive for the ‘Install Projects’ Category

Posted by OmegaMan at September 18, 2007

Category: Install Projects

Tags: ,

In researching a MSDN forum question I needed to see the current user’s credentials during a custom action during an Setup and Deployment project created from a Visual Studio 2005 project. My goal was to show a message box during install that would display the user’s credentials and domain.

What makes this project unique is that we will be using MessageBox, from the System.Windows.Forms namespace. This article shows you how to utilize a MessageBox in a custom action. Here are the steps

  1. Using this article as a basis Walkthrough: Creating a Custom Action we will do everything it does except do a Commit action.
  2. Add a reference to the dll project to include the System.Windows.Form namespace which will not be included by default.
  3. In the custom installer class created in the helper dll override the Install Method such as:
    public partial class ShowInfo : Installer
        public ShowInfo()
        // Add and override this method to show the current user and the domain.
        public override void Install(System.Collections.IDictionary stateSaver)
            WindowsIdentity wi = WindowsIdentity.GetCurrent();
            MessageBox.Show(string.Format("Name :{0}{1}System {2}", wi.Name, Environment.NewLine, Environment.UserDomainName));
    Then add these usings to the top of the file:
    using System.Windows.Forms;
    using System.Security.Principal;
  4. Then in the install project unlike the Walkthrough, add the custom dll to the Custom Actions operation in the Install Node.
  5. Build and install. Note the message box may come up behind other windows during install, so you may have to look.

This is a quick way to show information during an install for debug purposes or user info. Note it is a modal dialog and will stop processing until the user closes the message box window.

  • Recent Comments

    Thanks for this simple yet delightful code....
    Hey guys I'm having the same problem as Netanel KL { “Error HRESUL...
    Soluciono el problema con el primero (First step solved it for me)....
    Thank you! I was looking for this. You save my day!...
    Thank you! This was a big help. My requirement was a little differen...
    Thanks, after a small path adjustment it worked for Visual Studio 2015...
    Good call!...
    Thank you .. this helped...
    How about when you have a long string with no space? I tried it and it...
    Thank you, I ran into this same issues with Visual Studio 2015 after i...
  • Blog Stats

    • 138,579 hits