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:
- Download the sample script and extract the contents to the directory that contains the Visual Studio project you are working on
- Open the project in Visual Studio 2005
- Press F4 to display the Properties window
- Click on the name of your setup/deployment project in the Solution Explorer
- Click on the PostBuildEvent item in the Properties window to cause a button labeled "..." to appear
- Click on the "..." button to display the Post-build Event Command Line dialog
- Add the following command line in the Post-build event command line text box:
cscript.exe "$(ProjectDir)CustomAction_NoImpersonate.js" "$(BuiltOuputPath)"
- Build your project in Visual Studio 2005
<update date="1/17/2011"> Fixed broken download link to the sample script. </update>