Updated steps for setting the NoImpersonate flag for a custom action in Visual Studio 2005

A while back, I posted some instructions that can be used to run a post-build script to modify the custom action attributes of an MSI created by the Visual Studio 2005 setup/deployment project wizard.  This script is particularly useful to set the necessary attributes to make a custom action work correctly with User Account Control (UAC) on Windows Vista (as described in more detail in this blog post).

Since I posted those instructions, a couple of folks have contacted me to let me know that the jscript file provided in that post works correctly when it is run manually, but the steps to run it from within Visual Studio 2005 as a post-build step were failing.

I finally found some time to investigate this issue, and I discovered that I made a typo in the exact name of one of the variables being used in the post-build step.  This was a little tricky to narrow down because my typo was to spell the variable in what should be the correct way - $(BuiltOutputPath).  However, the actual variable name expected by MSBuild and Visual Studio 2005 is $(BuiltOuputPath) with the word spelled "ouput" instead of "output."

At any rate, I have modified the original post I wrote about this topic, and here are updated instructions that can be used to set the NoImpersonate bit in a Visual Studio 2005 setup project as well:

  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/17/2011"> Fixed broken download link to the sample script. </update>