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>
Comments
Anonymous
January 23, 2007
By Design. Ouput = Optimal Unrestricted Path Under Test Plus the spec doesn't mention the variable name. (Couldnt resist sticking up for the devs)Anonymous
January 23, 2007
Hi Samir - Thanks for letting me know about the OUPUT acronym. I hadn't realized that it stood for something :-)Anonymous
February 02, 2007
That error message was highly confusing. Thanks for the script, which appears to works perfectly.Anonymous
April 09, 2007
I am unable to download the script file. The link seems to be broken. I am having this exact problem. I am in very much need of the script so I can fix my install on Vista machines. Thanks...Anonymous
April 09, 2007
Hi Steve - My file server is currently down, but if you can contact me via email, I will be happy to send you a copy of this script. You can contact me by using http://blogs.msdn.com/astebner/contact.aspx or by emailing Aaron.Stebner (at) microsoft (dot) com. I'm sorry for the inconvenience.Anonymous
September 08, 2012
The comment has been removedAnonymous
September 09, 2012
Hi Richa - The macro described in this blog post is only valid in setup projects, and it must be spelled $(BuiltOuputPath) with the word "ouput" spelled incorrectly. Can you please confirm that you're using this macro in the correct type of project and if so, please also confirm that it is spelled exactly the way that it is listed in this blog post?Anonymous
September 10, 2012
Yes I was taking the macros from windows service project. I have now taken the property of setup projects...and it works fine :) Thanks a ton Aaron !!!