Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

Mailbag: How to set the NoImpersonate flag for a custom action in Visual Studio 2005

Mailbag: How to set the NoImpersonate flag for a custom action in Visual Studio 2005

  • Comments 69

Question:

I have built an installer using the Visual Studio 2005 setup project wizard.  It installs correctly on Windows XP but fails on Windows Vista.  I investigated and found that the failure on Windows Vista is caused by a custom action that fails with an access denied error.  However, I am running the setup with elevated privileges in Windows Vista.  How can I fix my setup so it will work correctly on Windows Vista?

Answer:

As Robert Flaming described in this blog post, it is necessary to set the NoImpersonate flag for custom actions that modify the system in Windows Vista.  This was an uninforced architectural intent that is now enforced in Windows Vista.

Unfortunately, there is not a way to directly set this flag for a custom action in the UI for the setup project in the Visual Studio IDE.  In Visual Studio 2005, you can use a post-build step that modifies the MSI to set this bit using a strategy previously described in this blog post.

You can use the following steps to set the NoImpersonate bit in a Visual Studio 2005 setup project:

  1. Download the sample script and extract the contents to the directory that contains the Visual Studio project you are working on
  2. Open the project in Visual Studio 2005
  3. Press F4 to display the Properties window
  4. Click on the name of your setup/deployment project in the Solution Explorer
  5. Click on the PostBuildEvent item in the Properties window to cause a button labeled "..." to appear
  6. Click on the "..." button to display the Post-build Event Command Line dialog
  7. Add the following command line in the Post-build event command line text box:
    cscript.exe "$(ProjectDir)CustomAction_NoImpersonate.js" "$(BuiltOuputPath)"
  8. Build your project in Visual Studio 2005

<update date="1/22/2007"> Updated command line in step 7.  The variable I had specified previously was incorrect.  It actually needs to be spelled wrong using "ouput" instead of "output" in the $(BuiltOuputPath) variable </update>

<update date="3/18/2009"> Fixed broken link to the sample script. </update>

 

  • Recently, I was helping a customer investigate an issue in an MSI-based installer that they created for

  • A while back, I posted some instructions that can be used to run a post-build script to modify the custom

  • If you have an installer for a Windows application that uses a custom action step during the installation process, you will likely hit this error message when trying to run that installer on Windows Vista: "The installer has encountered an unexpected

  • There are a few Visual Studio 2005 bugs that surface when building installation packages on a Windows

  • Question: I am using the Visual Studio 2005 web setup project wizard to create an MSI-based installer

  • I have added the following command line in the Post-build event command line text box:

    cscript.exe "$(ProjectDir)CustomAction_NoImpersonate.js" "$(BuiltOuputPath)"

    When I build the MSI installer project it shows following error.

    Error 1 'PreBuildEvent' failed with error code '1' 'Unspecified error'

    What s the solution for this ?

  • Hi Shajipd - The steps listed in this blog post will run customaction_noimpersonate.js as a post-build step, but from your comments it sounds like a pre-build step is failing.  Do you have any other commands listed in the Visual Studio pre-build steps?  I would suggest starting by looking at those to try to narrow down this error further.

  • Hi Aaron,

    I've tried to connect to the link to get CustomAction_noimpersonate.zip but the web page fails to be delivered... help please.

    Can you give an alternate site for this file?

    Thanks

    Q

  • Hi Qasper - I'm sorry, but my file server appears that it is down for maintenance for the holiday weekend.  I don't have an alternative download location.  If the site is not back up by the time I'm back at work on Tuesday, I will post the text of the script on my blog so you can copy and paste it and run it on your system.

    I'm sorry for the hassle that this has caused you.

  • Hi,

    I am also trying to download the ZIP file  CustomAction_noimpersonate.zip and unable to do so. If possible can you paste the file on bloag at earliest or give more hints so that I can write such script myself....

    Thanks,

    Jaydeep

  • I previously posted a set of steps that can be used to toggle the NoImpersonate bit for custom actions

Page 1 of 5 (69 items) 12345
Leave a Comment
  • Please add 7 and 7 and type the answer here:
  • Post