<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Aaron Margosis' &amp;quotNon-Admin&amp;quot and App-Compat WebLog : Vista/Win7</title><link>http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx</link><description>Tags: Vista/Win7</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>LUA Buglight 2.1 released</title><link>http://blogs.msdn.com/aaron_margosis/archive/2009/11/03/lua-buglight-2-1-released.aspx</link><pubDate>Tue, 03 Nov 2009 21:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916989</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/9916989.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=9916989</wfw:commentRss><description>&lt;P&gt;LUA Buglight 2.1, identifies admin-permissions issues ("LUA bugs") in desktop applications.&amp;nbsp; New version supports Windows 7 (x86 and x64), Vista (x86 and x64), XP (x86 only) and corresponding Server OSes.&lt;/P&gt;
&lt;P&gt;The download and more information is on this page:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/aaron_margosis/pages/LuaBuglight.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/pages/LuaBuglight.aspx"&gt;http://blogs.msdn.com/aaron_margosis/pages/LuaBuglight.aspx&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916989" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Fixing+LUA+Bugs/default.aspx">Fixing LUA Bugs</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/LUA+Buglight/default.aspx">LUA Buglight</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>Live, on the internet...</title><link>http://blogs.msdn.com/aaron_margosis/archive/2009/06/15/live-on-the-internet.aspx</link><pubDate>Tue, 16 Jun 2009 05:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9757715</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/9757715.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=9757715</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://en.wikipedia.org/wiki/Hello#Telephone" target=_blank mce_href="http://en.wikipedia.org/wiki/Hello#Telephone"&gt;Ahoy&lt;/A&gt;, all -- Later this week I'll be appearing at a virtual roundtable hosted by &lt;A href="http://www.microsoft.com/presspass/exec/techfellow/Russinovich/default.mspx" target=_blank mce_href="http://www.microsoft.com/presspass/exec/techfellow/Russinovich/default.mspx"&gt;Mark Russinovich&lt;/A&gt;, streaming live over the web.&amp;nbsp; The topic is Windows 7 application compatibility.&amp;nbsp; Among other things, I'll be demoing the latest&amp;nbsp;(still-unreleased) updates to&amp;nbsp;LUA Buglight (latest released version &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2008/11/06/lua-buglight-2-0-second-preview.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2008/11/06/lua-buglight-2-0-second-preview.aspx"&gt;here&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;Here are the details:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Springboard Series Virtual Roundtable&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;Windows 7 Application Compatibility: Your Questions Answered (Part 1)&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Date:&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Thursday,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;June 18&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Time:&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;11:00am Pacific Time&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;A href="https://ms.istreamplanet.com/springboard"&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-bidi-font-family: Calibri"&gt;https://ms.istreamplanet.com/springboard&lt;/SPAN&gt;&lt;/A&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Windows 7, is approaching fast and from the application standpoint is very similar to Windows Vista. We’re going to examine Windows 7 application compatibility not only from the perspective of moving from Windows Vista, but also for those coming from Windows XP. Join us to discuss the most common challenges around application compatibility when coming from a legacy operating system, why changes were made along the way, compatibility technologies inside the OS and methods for getting incompatible applications to run on Windows 7. Along the way we share tips and tricks, demonstrate free tools to analyze and fix applications and answer your specific questions about application compatibility live.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;In Part 2 of this Virtual Round Table discussion (planned for later this Summer/Fall), we’ll discuss the options and approaches for using virtualization tools In depth to address application incompatibilities – including presentation virtualization, desktop virtualization and application virtualization. We’ll be sending out more details and posting information to&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;A href="http://www.microsoft.com/springboard"&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-bidi-font-family: Calibri"&gt;www.microsoft.com/springboard&lt;/SPAN&gt;&lt;/A&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;for part 2 as the dates are finalized.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;As part of the “virtual” experience, you may submit your questions about Windows 7&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Application Compatibility to the panel live during the event—or submit questions in advance to&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;A href="mailto:vrtable@microsoft.com"&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #0070c0; mso-bidi-font-family: Calibri"&gt;vrtable@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;FONT face=Calibri&gt;Springboard Series: The resource for Windows desktop IT professionals&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 12pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9757715" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/LUA+Buglight/default.aspx">LUA Buglight</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>FAQ: How do I start a program as the desktop user from an elevated app?</title><link>http://blogs.msdn.com/aaron_margosis/archive/2009/06/06/faq-how-do-i-start-a-program-as-the-desktop-user-from-an-elevated-app.aspx</link><pubDate>Sat, 06 Jun 2009 07:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9702517</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/9702517.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=9702517</wfw:commentRss><description>&lt;P&gt;Common Vista/Win7 scenario:&amp;nbsp; the app you’ve written runs with elevated permissions, but then needs to start another program as the non-elevated desktop user.&amp;nbsp; For example, you want to display web content.&amp;nbsp; Now, you &lt;EM&gt;could&lt;/EM&gt; just launch the web browser from your app, and let the web browser run as admin.&amp;nbsp; What could go wrong?&amp;nbsp; (Hint:&amp;nbsp; the correct answer will include the word “catastrophic”)&lt;/P&gt;
&lt;P&gt;A very common mistake that programmers make is to grab a copy of the elevated, High Integrity Level access token from the current process and then “dumb it down”.&amp;nbsp; I.e., disable powerful group memberships, remove powerful privileges, and change the integrity level to Medium.&amp;nbsp; They then launch the new process with that “dumbed down” token.&amp;nbsp; This breaks for a number of reasons.&lt;/P&gt;
&lt;H2&gt;&lt;STRONG&gt;The new “LUA bug” of Vista/Win7&lt;/STRONG&gt;&lt;/H2&gt;
&lt;P&gt;First and foremost, that approach makes the invalid assumption that the elevated app is running under the same user identity as the desktop user who originally logged on.&amp;nbsp; This is the new “LUA bug” of Vista and Win7.&amp;nbsp; (Refresher:&amp;nbsp; “LUA” = “limited user account”; “LUA bug” = failure that occurs when running as LUA and not administrator.&amp;nbsp; #1 cause of LUA bugs:&amp;nbsp; assumption that the end user will be an administrator.)&amp;nbsp; In Vista/Win7, everything runs as “LUA” by default, unless you specifically allow something to run elevated.&amp;nbsp; If you’re a member of the Administrators group, by default this involves a simple “consent” prompt.&amp;nbsp; The resulting app still runs as you, but with full admin rights.&amp;nbsp; If you’re &lt;EM&gt;not &lt;/EM&gt;a member of Administrators, the elevation prompt requires the credentials of another account that is a member of Administrators.&amp;nbsp; The resulting app then runs &lt;STRONG&gt;&lt;EM&gt;as a different user&lt;/EM&gt;&lt;/STRONG&gt;.&amp;nbsp; A number of apps fail to take this second scenario into consideration.&amp;nbsp; “Dumbing down” the current process token is one example of that kind of failure.&amp;nbsp; The new program runs with reduced permissions, but &lt;STRONG&gt;&lt;EM&gt;not as the intended user&lt;/EM&gt;&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;There are at least a couple of other failures in that approach too, that are more obscure.&amp;nbsp; Let’s say you are a member of Administrators.&amp;nbsp; When you log on, the Windows LSA (Local Security Authority) generates two access tokens in two separate LSA-managed logon sessions.&amp;nbsp; One is the fully privileged, full-admin token; the other is the standard-user version, which is marked as linked to the full-admin token.&amp;nbsp; When you create a “dumbed-down” copy of the elevated one, the new token is still associated with the elevated session, and marked as being the “high half” of a split token.&amp;nbsp; As a result, if you start Internet Explorer with that token, Protected Mode will be disabled.&amp;nbsp; Also, if your “dumbed-down” process tries to launch an elevated app, it will simply launch the new process with the “dumbed-down” token, since it’s already marked as “elevated.”&lt;/P&gt;
&lt;H2&gt;“Enough nerditude.&amp;nbsp; Tell me what I need to do.”&lt;/H2&gt;
&lt;P&gt;So here’s one sequence that works well:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Enable the SeIncreaseQuotaPrivilege in your current token (&lt;A href="http://msdn.microsoft.com/en-us/library/aa446619.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa446619.aspx"&gt;sample&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;Get an HWND representing the desktop shell (&lt;A href="http://msdn.microsoft.com/en-us/ms633512(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/ms633512(VS.85).aspx"&gt;GetShellWindow&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;Get the Process ID (PID) of the process associated with that window (&lt;A href="http://msdn.microsoft.com/en-us/library/ms633522.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms633522.aspx"&gt;GetWindowThreadProcessId&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;Open that process (&lt;A href="http://msdn.microsoft.com/en-us/library/ms684320(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms684320(VS.85).aspx"&gt;OpenProcess&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;Get the access token from that process (&lt;A href="http://msdn.microsoft.com/en-us/library/aa379295.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa379295.aspx"&gt;OpenProcessToken&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;Make a primary token with that token (&lt;A href="http://msdn.microsoft.com/en-us/library/aa446617.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa446617.aspx"&gt;DuplicateTokenEx&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;Start the new process with that primary token (&lt;A href="http://msdn.microsoft.com/en-us/library/ms682434(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms682434(VS.85).aspx"&gt;CreateProcessWithTokenW&lt;/A&gt;) &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;I’ve attached an example C++ project, built with VS2008 and the MFC AppWizard, and tested with x86 and x64 builds.&amp;nbsp; The meat of the sample is in &lt;STRONG&gt;RunAsDesktopUser_Implementation.cpp&lt;/STRONG&gt;.&amp;nbsp; I’m sure it can be done in managed code, but that will be someone else’s project, not mine.&lt;/P&gt;
&lt;H2&gt;Caveats&lt;/H2&gt;
&lt;P&gt;Please note that there are a bunch of caveats about this approach:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;This runs the new program in the same context as the desktop shell.&amp;nbsp; If the desktop shell process is not running (crashed or intentionally terminated), GetShellWindow fails, and there is no process token to do anything with.&amp;nbsp; Also, GetShellWindow fails if the default shell (Explorer) has been replaced with a custom shell. &lt;/LI&gt;
&lt;LI&gt;If you have terminated the desktop shell and restarted it elevated (&lt;EM&gt;strongly discouraged&lt;/EM&gt;), then the new process will also run elevated – as will pretty much everything else you start. &lt;/LI&gt;
&lt;LI&gt;This code assumes that it is running already elevated.&amp;nbsp; If you’re not running elevated, then there is no need for this code.&amp;nbsp; If you’re not running as admin, then the necessary step of enabling SeIncreaseQuotaPrivilege won’t work anyway. &lt;/LI&gt;
&lt;LI&gt;CreateProcessWithTokenW requires Vista or newer.&amp;nbsp; So:&amp;nbsp; this approach won’t work on pre-Vista (e.g., XP with runas); &lt;EM&gt;and &lt;/EM&gt;if you want to incorporate this code in a program that can run on XP/2003, you need to use LoadLibrary/GetProcAddress to get the CreateProcessWithTokenW entry point. &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9702517" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/aaron_margosis/attachment/9702517.ashx" length="73975" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>The Return of PrivBar (x86 and x64)</title><link>http://blogs.msdn.com/aaron_margosis/archive/2008/08/15/the-return-of-privbar-x86-and-x64.aspx</link><pubDate>Fri, 15 Aug 2008 09:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8868889</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/8868889.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=8868889</wfw:commentRss><description>&lt;P&gt;I recently switched internet service providers, not realizing when I did that &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/195350.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/195350.aspx"&gt;PrivBar&lt;/A&gt; and &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx"&gt;MakeMeAdmin&lt;/A&gt; would suddenly disappear from the internet when they un-provisioned my space on their servers.&amp;nbsp; Oops.&lt;/P&gt;
&lt;P&gt;To try to compensate you for the inconvenience, PrivBar is now available once again,&amp;nbsp;now in x86 &lt;EM&gt;and&lt;/EM&gt; x64 versions.&amp;nbsp; So if you are running an x64 version of Windows (XP or higher), you can now use PrivBar in all Explorer and Internet Explorer windows.&amp;nbsp; (It will also tell you whether that particular instance is running 32-bit or 64-bit code.)&lt;/P&gt;
&lt;P&gt;Note that by default on x64, Explorer.exe is 64-bit, but IE is 32-bit; but there are, in fact, 32-bit and 64-bit versions of both programs.&amp;nbsp; A 32-bit process can load only 32-bit DLLs, and a 64-bit process can load only 64-bit DLLs.&amp;nbsp; The main IE icons you see point to the 32-bit versions, because the vast majority of IE add-ons, ActiveX controls, etc., are 32-bit:&amp;nbsp; the 64-bit version of IE cannot load those ActiveX controls, so sites like youtube don't do much.&lt;/P&gt;
&lt;P&gt;Click &lt;A class="" href="http://aaronmargosis.members.winisp.net/PrivBar/PrivBar.1.0.3.0.zip" mce_href="http://aaronmargosis.members.winisp.net/PrivBar/PrivBar.1.0.3.0.zip"&gt;here&lt;/A&gt; for the PrivBar binaries; click &lt;A class="" href="http://aaronmargosis.members.winisp.net/PrivBar/PrivBar_source.1.0.3.0.zip" mce_href="http://aaronmargosis.members.winisp.net/PrivBar/PrivBar_source.1.0.3.0.zip"&gt;here&lt;/A&gt; if you want the slightly-updated source code and Visual Studio 2008 project files.&lt;/P&gt;
&lt;P&gt;Instructions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Extract PrivBar.dll from &lt;A class="" href="http://aaronmargosis.members.winisp.net/PrivBar/PrivBar.1.0.3.0.zip" mce_href="http://aaronmargosis.members.winisp.net/PrivBar/PrivBar.1.0.3.0.zip"&gt;the zip file&lt;/A&gt; and put it somewhere where all users have Read access to it.&amp;nbsp; If you're running an x64 version of Windows, extract PrivBarX64.dll to the same location.&lt;/LI&gt;
&lt;LI&gt;At a command prompt running as admin, run&lt;BR&gt;&lt;FONT face="courier new"&gt;&lt;STRONG&gt;regsvr32 &lt;I&gt;path&lt;/I&gt;\PrivBar.dll&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;where &lt;FONT face="courier new"&gt;&lt;I&gt;&lt;STRONG&gt;path&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt; is the folder location to which you extracted PrivBar.dll.&amp;nbsp; If you're running x64, do the same with PrivBarX64.dll.&amp;nbsp; Note that you have to be running as (fully-elevated) admin in order to do this, and that trying to register the x64 version on 32-bit Windows will fail.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;No need for the extra .reg file anymore.&amp;nbsp; You can now enable the bar in Explorer or in IE by choosing View / Toolbars / PrivBar, as before.&lt;/P&gt;
&lt;P&gt;(BTW -- MakeMeAdmin is back online, too.)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8868889" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>LUA Buglight 2.0 - preview</title><link>http://blogs.msdn.com/aaron_margosis/archive/2008/06/13/lua-buglight-2-0-preview.aspx</link><pubDate>Fri, 13 Jun 2008 07:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8594021</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/8594021.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=8594021</wfw:commentRss><description>&lt;P&gt;Attached to this blog post is a &lt;EM&gt;PREVIEW VERSION&lt;/EM&gt; of LUA Buglight 2.0.&amp;nbsp; LUA Buglight is a utility that helps identify "LUA bugs" in desktop applications -- the bugs that appear when the application is run as a standard user instead of as an administrator.&lt;/P&gt;
&lt;P&gt;Some of the improvements in LUA Buglight 2.0 over its predecessor:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Much better Vista support&lt;/LI&gt;
&lt;LI&gt;Streamlined&amp;nbsp;UI and improved flow&lt;/LI&gt;
&lt;LI&gt;Identifies more bugs&lt;/LI&gt;
&lt;LI&gt;On XP, not restricted to using a local account to create the admin context&lt;/LI&gt;
&lt;LI&gt;On Vista, prompts for elevation just one time per session instead of for each test&lt;/LI&gt;
&lt;LI&gt;User options saved to the registry&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;There are more improvements and refinements that I want to make, but I think you'll find it is quite usable now.&amp;nbsp; And I promised some audiences here at Tech*Ed that I would post a preview version here prior to my Friday morning session introducing LUA Buglight 2.0. :-)&lt;/P&gt;
&lt;P&gt;Note that I haven't written up new documentation yet, and that these binaries have not been signed yet.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Update, June 14:&amp;nbsp; &lt;/EM&gt;&lt;/STRONG&gt;Yes - meant to mention - LUA Buglight is designed only&amp;nbsp;for x86.&amp;nbsp; I'll add a processor check on startup.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=+1&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=red&gt;Update, November 6:&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp; Removing the attachment, because the Second Preview version is now available &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2008/11/06/lua-buglight-2-0-second-preview.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2008/11/06/lua-buglight-2-0-second-preview.aspx"&gt;here&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8594021" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Fixing+LUA+Bugs/default.aspx">Fixing LUA Bugs</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/LUA+Buglight/default.aspx">LUA Buglight</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>How to cleanly stop Explorer.exe on Windows Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/17/how-to-cleanly-stop-explorer-exe-on-windows-vista.aspx</link><pubDate>Wed, 18 Jul 2007 00:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3924164</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/3924164.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=3924164</wfw:commentRss><description>&lt;P&gt;This is the first time I have blogged here about something other than running with least privilege. It's about a neat trick, though, that can be useful for some people. &lt;/P&gt;
&lt;P&gt;If you need to shut down the main Explorer process, you &lt;EM&gt;could&lt;/EM&gt; just kill it from Task Manager or &lt;A href="http://www.microsoft.com/technet/sysinternals/utilities/processexplorer.mspx" mce_href="http://www.microsoft.com/technet/sysinternals/utilities/processexplorer.mspx"&gt;Process Explorer&lt;/A&gt;. But undesirable and unpredictable things can happen when you abruptly kill &lt;EM&gt;any&lt;/EM&gt; process, particularly one as central as Explorer. &lt;/P&gt;
&lt;P&gt;In Windows XP, you can get Explorer to exit cleanly by getting to the shutdown dialog (e.g., Start / Turn Off Computer, or Start/Shutdown), then hold down the Ctrl+Alt+Shift keys and click the "Cancel" button. (Ref: &lt;A href="http://blogs.msdn.com/jeffdav/archive/2004/07/22/191636.aspx" mce_href="http://blogs.msdn.com/jeffdav/archive/2004/07/22/191636.aspx"&gt;JeffDav's blog&lt;/A&gt;.) &lt;/P&gt;
&lt;P&gt;In Windows Vista with its standard Start Menu, click on the Start button. Hold down Ctrl+Shift and right-click on any empty area of the menu or on the power/lock buttons at the bottom of the right half of the menu. One of the context menu choices is "Exit Explorer". Choose this and the main Explorer process will cleanly shut itself down. (Thanks to Mike Sheldon and Raymond Chen for this tip.) &lt;/P&gt;
&lt;P&gt;If you are using the "Classic Start Menu" option in Vista, the XP Ctrl+Alt+Shift+Cancel method still works. &lt;/P&gt;
&lt;P&gt;OK, so chances are right now you're looking at nothing but wallpaper and the Sidebar and wondering, "What do I do now?" There's no Start menu anymore, and Win+R doesn't display the Run dialog. Answer: press Ctrl+Shift+Esc. This starts Task Manager. In Task Manager, choose "File / New Task (Run)", type "Explorer" and click OK. The shell will come back to life. &lt;/P&gt;
&lt;P&gt;Note that on both Windows XP and Windows Vista, only the "main" Explorer process exits – that is, the process that manages the Start menu, taskbar, and desktop. With default settings, all Explorer folder windows are managed by that process as well, and so they will close too. However, if you have configured Explorer to "launch folder windows in a separate process", then those folder windows will not close when you apply this trick. Furthermore, when I tried this on Windows XP, I needed to manually close all those folder windows before running a new instance of Explorer would display the taskbar, etc., instead of just displaying yet another folder window. &lt;/P&gt;
&lt;P&gt;Why is this hidden nugget even there? Its purpose is to help developers and testers who work on shell extensions to be able to stop and restart Explorer quickly and cleanly without having to log out. &lt;/P&gt;
&lt;P&gt;Obviously, though, this trick can also be used to launch Explorer elevated. If you've exited the shell process and start Explorer from an elevated context, the &lt;EM&gt;entire desktop shell&lt;/EM&gt; will run elevated. &lt;STRONG&gt;I cannot say this without adding caveats.&lt;/STRONG&gt; If you do this, &lt;EM&gt;everything&lt;/EM&gt; you start from this point on will run elevated. Shell extensions will run elevated, including the ones with serious security flaws. If you shut down Explorer again, any child processes that were launched will continue to run elevated, including browsers, IM clients, etc., with all the risk that incurs. IE Protected Mode does not operate when IE is running elevated. Less important but also significant is that any processes running at Medium IL will not be able to interact with the elevated shell – for example, to display taskbar notification icons. In general, because Explorer was neither designed for nor tested with this kind of elevated execution, you should not assume that &lt;EM&gt;anything&lt;/EM&gt; will work correctly, including something as fundamental as user logoff. If you &lt;EM&gt;really&lt;/EM&gt; need an elevated Explorer window on Vista, you can try the unsupported trick I described in &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/28/and-so-this-is-vista.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/28/and-so-this-is-vista.aspx"&gt;this post&lt;/A&gt; instead of elevating the entire shell.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3924164" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx</link><pubDate>Sun, 01 Jul 2007 08:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3636427</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/3636427.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=3636427</wfw:commentRss><description>&lt;P&gt;&lt;EM&gt;[Added 2007-07-02, 16:41 Eastern Time:&amp;nbsp; I was thoroughly and inexcusably remiss in failing to include a reference to Michael Murgolo's excellent TechNet Magazine article, &lt;/EM&gt;&lt;A class="" href="http://www.microsoft.com/technet/technetmag/issues/2007/06/UtilitySpotlight/default.aspx" mce_href="http://www.microsoft.com/technet/technetmag/issues/2007/06/UtilitySpotlight/default.aspx"&gt;&lt;EM&gt;Script Elevation PowerToys for Windows Vista&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;.&amp;nbsp; I'm rectifying that now.]&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;As I mentioned &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/28/and-so-this-is-vista.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/28/and-so-this-is-vista.aspx"&gt;recently&lt;/A&gt;, although the RunAs.exe console utility still exists on Windows Vista and will let you run a program as another user, it will not run that program with elevated privileges. So if you use RunAs.exe to start a program with an administrator account, the program will run with that account's profile and settings, but with standard user privileges only, not with the power to do computer administration. You can't get an application to run with elevated privileges unless you go through the UAC elevation prompt. And RunAs.exe on Windows Vista (RTM, anyway) will not invoke that prompt. &lt;/P&gt;
&lt;P&gt;What if you have batch files for XP or Server 2003 that called RunAs when administrative tasks needed to be performed? E.g., say there's a line in your batch file to start CMD.EXE with elevated permissions that looks like this: &lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Courier New"&gt;runas /u:Administrator "cmd.exe /t:fc /k cd /d c:\ &amp;amp;&amp;amp; title *** Admin console *** " &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Is there another way to script the "run this program with elevated permissions" that RunAs gave you on XP/2003? Yes. First, create a small script file called "elevate.js" and put it in a folder in your PATH. (*) The contents of elevate.js should look like this: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE&gt;// elevate.js -- runs target command line elevated
if (WScript.Arguments.Length &amp;gt;= 1) {
    Application = WScript.Arguments(0);
    Arguments = "";
    for (Index = 1; Index &amp;lt; WScript.Arguments.Length; Index += 1) {
        if (Index &amp;gt; 1) {
            Arguments += " ";
        }
        Arguments += WScript.Arguments(Index);
    }
    new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas");
} else {
    WScript.Echo("Usage:");
    WScript.Echo("elevate Application Arguments");
}
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then replace "runas /u:Administrator" with "elevate": (**) &lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Courier New"&gt;elevate cmd.exe "/t:fc /k cd /d c:\ &amp;amp;&amp;amp; title *** Admin console *** " &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Important note&lt;/EM&gt;&lt;/STRONG&gt;: the elevate.js script invokes the UAC prompt, but &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/29/faq-why-can-t-i-bypass-the-uac-prompt.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/29/faq-why-can-t-i-bypass-the-uac-prompt.aspx"&gt;it will not let you bypass it&lt;/A&gt;. User interaction is still required. &lt;/P&gt;
&lt;P&gt;With the default settings, the elevation prompt will prompt you for simple consent (click "continue") if you are a member of the Administrators group, and prompt you for admin credentials if you are running as a standard user. If you are a member of the Administrators group, but would like to use a different account for the elevated task, you can change the computer's security policy for the behavior of the elevation prompt for admins to "Prompt for credentials". When the prompt appears, you can enter the credentials of a different administrative account. &lt;/P&gt;
&lt;P&gt;Thanks to John Stephens of the Windows team for this script. &lt;/P&gt;
&lt;P&gt;(*)&amp;nbsp;&amp;nbsp;I highly recommend that scripts and other programs that may be used by elevated apps or are part of elevation sequences be kept in a folder that standard users cannot write to. I have a Utilities folder under %ProgramFiles% for this purpose. &lt;/P&gt;
&lt;P&gt;(**)&amp;nbsp;&amp;nbsp;Note that the quoting in this case needed to be rearranged a little as well: the first item passed to the script is the application to elevate; everything after that forms the rest of the command line for that application. If the quoting had been kept as-is, Windows would have tried to elevate an application called "cmd.exe /t:fc /k …", which doesn't exist. The quotes are still needed here so that the "&amp;amp;&amp;amp;" and everything after it remain on the command line to the elevated application. Otherwise the current command shell will parse it as part of the command &lt;EM&gt;it&lt;/EM&gt; is running. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3636427" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>FAQ:  Why can’t I bypass the UAC prompt?</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/06/29/faq-why-can-t-i-bypass-the-uac-prompt.aspx</link><pubDate>Sat, 30 Jun 2007 06:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3614846</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/3614846.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=3614846</wfw:commentRss><description>&lt;P&gt;The frequently asked question, "Why can't I bypass the UAC prompt?" is often accompanied by statements like one or more of the following: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"We want our application to run elevated automatically without prompting the user." &lt;/LI&gt;
&lt;LI&gt;"I don't get why I can't authorize an application ONCE and be done with it." &lt;/LI&gt;
&lt;LI&gt;"Unix has &lt;EM&gt;setuid root&lt;/EM&gt; which lets you run privileged programs securely." &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The designers of Windows Vista's User Account Control expressly decided not to incorporate functionality like &lt;A href="http://en.wikipedia.org/wiki/Setuid" mce_href="http://en.wikipedia.org/wiki/Setuid"&gt;setuid/suid&lt;/A&gt; or &lt;A href="http://en.wikipedia.org/wiki/Sudo" mce_href="http://en.wikipedia.org/wiki/Sudo"&gt;sudo&lt;/A&gt; found in Unix and Unix-like OSes such as Mac OS X. I think they made the right decision. &lt;/P&gt;
&lt;P&gt;As I'm sure everyone knows, large parts of the Windows ecosystem have a long legacy of assuming that the end user has administrative permissions, and consequently a lot of programs work correctly only when run that way. (I'm not going to delve into that history here, nor will I entertain any finger-pointing on the topic at this time. One of these days I'll post my thoughts on that subject.) As computer security has become increasingly important, breaking that cycle became absolutely imperative. It is with the release of Windows Vista that the first major move in that direction is achieved. Indeed, the primary purpose of the technologies that comprise UAC is to make the "standard user" the default for Windows, encouraging software developers to create applications that do not require admin. It's not perfect by any means, but changing the ecosystem will take a long time, and UAC is a good first step. &lt;/P&gt;
&lt;P&gt;Pre-approving code to run with elevated permissions without going through an elevation prompt, as described in the bulleted scenarios above, seems at first glance to be both useful and convenient. However, the negatives far outweigh those benefits. In particular: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The "standard user by default" vision would become impossible and ultimately never happen; &lt;/LI&gt;
&lt;LI&gt;Elevation of privilege (EoP) would be trivial – &lt;EM&gt;any&lt;/EM&gt; compromise could lead to full system compromise. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If it were possible to mark an application to run with silently-elevated privileges, what would become of all those apps out there with &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2006/02/06/525455.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2006/02/06/525455.aspx"&gt;LUA bugs&lt;/A&gt;? Answer: they'd all be marked to silently elevate. How would future software for Windows be written? Answer: To silently elevate. Nobody would actually fix their apps, and end-user applications will continue to require and run with full administrative permissions unnecessarily. &lt;/P&gt;
&lt;P&gt;What if the application could not mark itself for silent elevation but instead had to be marked by the consumer or enterprise administrator installing the application? Answer: the developer of the installation program (which necessarily runs with admin/system permissions in order to install machine-wide) would figure out where the setting lived, and set it. (Several major ISVs told us directly that they would in fact do exactly that.) There would be no real way to protect that setting from anything running as admin. This would be especially true if it were settable via Group Policy (which would be expected, if not demanded). &lt;/P&gt;
&lt;P&gt;"Well, so what? We're only talking about applications I approved!" OK, let's say that's true, but how do you ensure that a malicious user cannot use the application for purposes other than those for which it was intended? And at least as important – how do you ensure that malware that has infected the user's session cannot drive a setuid application programmatically to take over the system? Ensuring strict behavioral boundaries for complex software running with elevated privileges is (at best) incredibly difficult. And ensuring that it is free of exploitable design and implementation bugs is far beyond the capabilities of software engineering today. The complexity and risk compounds when you consider how many apps have extensibility points that load code that you or your IT admin may not be aware of, or that can load code or consume data from user-writable areas with minimal if any validation. &lt;/P&gt;
&lt;P&gt;Privilege escalation due to setuid and sudo has plagued Unix-like systems for many years, and continues to do so. In fact, several of the bugs in the recent &lt;A href="http://projects.info-pull.com/moab/" mce_href="http://projects.info-pull.com/moab/"&gt;Month of Apple Bugs&lt;/A&gt; fell into this category. Follow these links for lots more references: (*) &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://secunia.com/search/?search=SETUID&amp;amp;adv_search=1&amp;amp;s=1&amp;amp;w=0&amp;amp;vuln_title=1&amp;amp;vuln_bodytext=1&amp;amp;critical%5B%5D=0&amp;amp;impact%5B%5D=3&amp;amp;where%5B%5D=3" mce_href="http://secunia.com/search/?search=SETUID&amp;amp;adv_search=1&amp;amp;s=1&amp;amp;w=0&amp;amp;vuln_title=1&amp;amp;vuln_bodytext=1&amp;amp;critical%5B%5D=0&amp;amp;impact%5B%5D=3&amp;amp;where%5B%5D=3"&gt;Secunia items re SETUID and local privilege escalation&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://secunia.com/search/?search=SUID&amp;amp;adv_search=1&amp;amp;s=1&amp;amp;w=0&amp;amp;vuln_title=1&amp;amp;vuln_bodytext=1&amp;amp;critical%5B%5D=0&amp;amp;impact%5B%5D=3&amp;amp;where%5B%5D=3" mce_href="http://secunia.com/search/?search=SUID&amp;amp;adv_search=1&amp;amp;s=1&amp;amp;w=0&amp;amp;vuln_title=1&amp;amp;vuln_bodytext=1&amp;amp;critical%5B%5D=0&amp;amp;impact%5B%5D=3&amp;amp;where%5B%5D=3"&gt;Secunia items re SUID and local privilege escalation&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://applefun.blogspot.com/search/label/privilege%20escalation" mce_href="http://applefun.blogspot.com/search/label/privilege%20escalation"&gt;MOAB posts involving privilege escalation&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.symantec.com/enterprise/security_response/weblog/2007/05/the_danger_of_speling_mistakes.html" mce_href="http://www.symantec.com/enterprise/security_response/weblog/2007/05/the_danger_of_speling_mistakes.html"&gt;Symantec write-up on how easy it is to subvert sudo&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.securityfocus.com/archive/1/395107/2005-04-03/2005-04-09/0" mce_href="http://www.securityfocus.com/archive/1/395107/2005-04-03/2005-04-09/0"&gt;Ease of exploiting a sudo authn "grace period"&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In the past, elevation of privilege has tended not to be noticed in Windows – there is no real "elevation" if you're already running as admin. (**) With the Vista shift toward "standard user", EoP threats become much more important, and it is vital that Windows do as much as practical to mitigate them. That is also why Windows services are no longer able to interact with the user desktop. Taking on the setuid headaches that *nix has had to live with does not seem like a profitable deal. &lt;/P&gt;
&lt;P&gt;We expect that in ordinary day-to-day usage, users should rarely, if ever, see elevation prompts, since most should rarely, if ever, have to perform administrative tasks – and never in a well-managed enterprise. Elevation prompts are to be expected when setting up a new system or installing new software. Beyond that, they should be infrequent enough that they catch your attention when they occur, and not simply trigger a reflexive approval response. This will increasingly be the case as more software conforms to least-privilege norms, and as improvements in the Windows user experience reduces prompting further. &lt;/P&gt;
&lt;P&gt;Having said all that, there &lt;EM&gt;is&lt;/EM&gt; a Local Security Policy option to change the behavior of the elevation prompt for Administrators to "elevate without prompting". With this option selected, &lt;EM&gt;anything&lt;/EM&gt; that requests elevation gets elevated without prompting the user. (The default setting is "prompt for consent"; the third option is "prompt for credentials". Note that "elevate without prompting" is available only for members of the Administrators group. The options for standard users are "prompt for credentials" and "automatically deny elevation requests".) While "elevate without prompting" may be useful &lt;EM&gt;in well-constrained, secure environments&lt;/EM&gt; for automated testing and possibly for initial system setup, having this option selected otherwise is very risky and strongly discouraged. (Note also that Vista's Home SKUs do not include the policy editor.) &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Nitpicker's corner&lt;/STRONG&gt; (***)&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(*) Pointing out the obvious: local privilege escalation by definition means that the bad actor is already on your system. However, there's a &lt;EM&gt;huge&lt;/EM&gt; difference between malware running as you (non-admin) and malware running with root privileges.&amp;nbsp; If there weren't, there would be no point (from a security point of view) in running with least privilege. &lt;/P&gt;
&lt;P&gt;(**) "Elevation of privilege" in this context means "&lt;EM&gt;unauthorized&lt;/EM&gt; elevation of privilege". Technically, yes, Administrator is not as powerful as System (in that there are operations that Administrator will get Access Denied where System will succeed), and System is not as powerful as kernel-mode code (in that there are operations that fail for user-mode code running as System that succeed when called from kernel code). However, two of the things that Administrator &lt;EM&gt;is&lt;/EM&gt; authorized to do include: 1) configuring arbitrary code to run as System, and running it; and 2) loading arbitrary code into the kernel, and running it. Hence, if code is running as admin, there is nothing it is not authorized to do. &lt;/P&gt;
&lt;P&gt;(***) "Nitpicker's corner" might be a trademark of &lt;A href="http://blogs.msdn.com/oldnewthing/" mce_href="http://blogs.msdn.com/oldnewthing/"&gt;The Old New Thing&lt;/A&gt;. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3614846" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>And so this is Vista…</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/06/28/and-so-this-is-vista.aspx</link><pubDate>Thu, 28 Jun 2007 21:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3588300</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>29</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/3588300.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=3588300</wfw:commentRss><description>&lt;P&gt;What becomes of all my earlier non-admin tips, tricks and recommendations vis-à-vis &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/06/23/163229.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/06/23/163229.aspx"&gt;RunAs&lt;/A&gt;, &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx"&gt;MakeMeAdmin&lt;/A&gt;, &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/195350.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/195350.aspx"&gt;PrivBar&lt;/A&gt; and their interactions with &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/07/175488.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/07/175488.aspx"&gt;IE and Explorer&lt;/A&gt;? The short answer is that Vista changes just about everything with respect to running with least privilege. &lt;/P&gt;
&lt;P&gt;Windows Vista makes running as a standard user (non-admin) much more pleasant, feasible and secure than it was on XP. I'm not going to drill into all those improvements here. Instead, the focus of this post is to update my earlier posts about running on XP as a standard user (the "Running as Admin Only When Required" posts in the &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2005/04/18/TableOfContents.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2005/04/18/TableOfContents.aspx"&gt;Table of Contents&lt;/A&gt;) as they pertain to Windows Vista. To save some space, I'll assume you've spent at least a little time running Vista. &lt;/P&gt;
&lt;H2&gt;MakeMeAdmin &lt;/H2&gt;
&lt;P&gt;Let's start with &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx"&gt;MakeMeAdmin&lt;/A&gt;. Vista renders MakeMeAdmin obsolete. On XP/2003, MakeMeAdmin lets you run as a standard user, and temporarily elevate your standard account to run a selected program with administrative privileges. Vista gives you the same ability, but with more convenience &lt;EM&gt;and&lt;/EM&gt; more safety than MakeMeAdmin could provide. &lt;/P&gt;
&lt;P&gt;If you are a member of the Administrators group on Vista, it's effectively the same as being a standard user, as long as you never run anything elevated: all your admin rights and privileges are disabled. Elevating an application does essentially the same thing that MakeMeAdmin did, but more conveniently, and more securely. Here's why: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The convenience is that by default it's a simple one-click confirmation in a "consent" dialog, rather than having to enter two passwords in two console windows. &lt;/LI&gt;
&lt;LI&gt;Elevating an application using "consent" requires non-spoofable user interaction. By non-spoofable, I mean that malware with normal user privileges can make a UI look like the consent prompt, but it can't elevate anything. Further, the consent prompt appears on the secure "winlogon" desktop, which cannot be seen or manipulated by unprivileged code. Even if low-privileged malware steals your password, it can't get anything to run elevated without the interactive user going through the elevation UI. On XP, malware that obtained the password for an admin account could run programs with full admin privileges at any time. &lt;/LI&gt;
&lt;LI&gt;"Elevated" applications on Windows XP running on the same desktop with lower-privileged programs were subject to "shatter attacks" – the lower-privileged programs sending window messages to the windows of higher-privileged applications and driving them programmatically, or exploiting buffer overflows to run arbitrary code in the "elevated" context. With Windows Vista's Mandatory Integrity Control (MIC) and User Interface Privilege Isolation (UIPI), this becomes more difficult. (See Mark Russinovich's &lt;A href="http://www.microsoft.com/technet/technetmag/issues/2007/06/UAC/default.aspx" mce_href="http://www.microsoft.com/technet/technetmag/issues/2007/06/UAC/default.aspx"&gt;recent TechNet Magazine article&lt;/A&gt; for more information.)&lt;EM&gt; &lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You have to be careful about what you choose to elevate, but the same was true with MakeMeAdmin, too. &lt;/P&gt;
&lt;H2&gt;RunAs &lt;/H2&gt;
&lt;P&gt;Windows XP provided two interfaces for "RunAs" – the "right-click" dialog version, and the runas.exe console application. The dialog version has been replaced by the "Run as administrator" option. The console utility is still there, but it has limitations. &lt;/P&gt;
&lt;P&gt;The Windows Shell team probably knows for sure, but I'm willing to guess that the main reason people used the "Run As" dialog on XP (probably only a tiny percentage ever used it anyway) was to run a program with admin permissions, and that for this purpose, "Run as administrator" serves as a superior substitute. With the default settings, a member of Administrators can use it as a MakeMeAdmin replacement (see above); a standard user gets a dialog that lets them enter the credentials of any admin account and run the target program with those credentials, also gaining the security improvements of UIPI as well as the secure desktop UI. One complaint I have seen in my blog's comments is that a member of Administrators can't choose to run as a different admin user, such as a Domain Admin account. This can be addressed by changing the elevation behavior for administrators from "prompt for consent" to "prompt for credentials". &lt;/P&gt;
&lt;P&gt;The runas.exe console utility still exists, and it will let you run a program as a different user, but not with elevated permissions. If you specify an admin account, for example, you get the "filtered token" for that account, with admin groups and privileges disabled. As mentioned earlier, you'd need to go through the elevation UI to get the "full token". &lt;/P&gt;
&lt;P&gt;Runas.exe is not as secure as the elevation UI. Runas.exe runs and collects credentials in the security context of the logged-on user, and so any malware running as that user can take control of that process, monitor the keystrokes going into it, changing the target program, etc. By contrast, the elevation UI collects credentials on the secure "winlogon" desktop (by default), which is accessible only to code running as System. &lt;/P&gt;
&lt;P&gt;One thing that hasn't changed with runas.exe is that it still requires credential entry at the keyboard – you can't pipe in a password through stdin or in the command line. This is to help discourage the insecure practice of putting plain-text passwords in script files. (Answering one of the most commonly-asked questions in my blog's comments.) &lt;/P&gt;
&lt;H2&gt;Browsing the file system with Internet Explorer, and running IE and Windows Explorer as a different user &lt;/H2&gt;
&lt;P&gt;Internet Explorer used to be able to browse the file system. Beginning with IE7, that became history, both on XP and Vista. If you enter a file system path into the IE7 address bar, it will open a new Windows Explorer window to that path. From a security perspective, it seems like a pretty good idea not to allow the main program that interacts with that hostile world known as the Internet to also interact with your file system in the same way. &lt;/P&gt;
&lt;P&gt;This change broke scenarios for a number of people who had found IE to be more "RunAs-friendly" than Windows Explorer for browsing the file system with elevated privileges. Windows Explorer on XP can be made more RunAs-friendly – see the SeparateProcess advice I posted &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/07/175488.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/07/175488.aspx"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;On Vista, however, there are more changes. Neither Internet Explorer nor Windows Explorer is willing to entertain multiple accounts on the same desktop. If you try to run IE under a different user account from that of the desktop, it will display an error message: "The RUNAS command is not supported." As I understand it, the primary reason is that with Protected Mode Internet Explorer, which runs at Low Integrity Level, IE also launches a Medium IL broker process (ieuser.exe) which runs as the desktop user and which gates selected Medium IL operations for the Low IL process. Allowing multiple identities into that mix would have introduced significant complexity best avoided. If you try to run Windows Explorer as a different user, you'll see nothing – the new process starts but exits without displaying a window. &lt;/P&gt;
&lt;P&gt;However, I have found that it is possible for a member of the Administrators group to run both IE and Explorer with elevated privileges. With IE, right-click its icon in the QuickLaunch or in the All Programs menu (not at the top of the Start Menu) and choose "Run as administrator". One thing you'll (hopefully) notice is that the UAC elevation prompt for Internet Explorer shows it as "an unidentified program" from an "unidentified publisher", rather than as a Windows component or other signed program from a trusted publisher. As I understand it, the reason for this is because systems will quite often have IE plug-ins that are not signed and which may introduce more risk than the user may be aware of. Hence, the "unsigned" prompt is intended to discourage running IE with full admin privileges. &lt;/P&gt;
&lt;P&gt;Explorer is a little trickier. Directly applying "Run as administrator" won't do it, but running it from an elevated command shell often will. I find that a command line like "explorer /e,c:\" will work, while just running "explorer" might not. But &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/07/175488.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/07/175488.aspx"&gt;as before&lt;/A&gt;: if it works at all, it is an unintentional side effect of the current implementation, and is subject to change at any time. &lt;/P&gt;
&lt;P&gt;How can you tell whether it worked? &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/195350.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/195350.aspx"&gt;PrivBar&lt;/A&gt; still works on Vista, both for Internet Explorer and Windows Explorer.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3588300" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>Follow-up on "Setting color for *all* CMD shells based on admin/elevation status"</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/06/27/follow-up-on-setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx</link><pubDate>Thu, 28 Jun 2007 04:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3529769</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/3529769.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=3529769</wfw:commentRss><description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;[Updated, 2007-06-27]&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the (overdue) follow-up to my &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2007/02/22/setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2007/02/22/setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx"&gt;earlier blog post&lt;/A&gt; about setting the color and title of all CMD windows based on the admin/elevation status of that window.&lt;/P&gt;
&lt;P&gt;First of all, as some commenters noted -- and as I had discovered as well -- having the COLOR command run in the CMD autorun causes strange build failures in Visual Studio (at least in C++ projects) when it invokes commands via CMD.&amp;nbsp; My workaround is to specify the COLOR command only in the branch that I don't run Visual Studio in.&amp;nbsp; E.g., I always run Visual Studio as a non-admin, so I keep the "COLOR FC" statement in the admin branch, and don't run any COLOR statement in the non-admin branch.&amp;nbsp; If you always build as an elevated/admin, then you should reverse that so that the COLOR statement runs in the non-admin branch -- or don't use COLOR to differentiate and instead just use TITLE.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;[Added 2007-06-27]&amp;nbsp; &lt;/EM&gt;&lt;/STRONG&gt;It turns out that following COLOR with a &lt;EM&gt;single &lt;/EM&gt;ampersand and another command makes the build problem go away!&lt;/P&gt;
&lt;P&gt;Second, &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2007/02/22/setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx#1745779" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2007/02/22/setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx#1745779"&gt;Pavel&amp;nbsp;suggested a more portable test&lt;/A&gt; than bootcfg/bcdedit:&amp;nbsp; &lt;EM&gt;cacls.exe %windir%\system32\config\systemprofile&lt;/EM&gt;.&amp;nbsp; That folder grants access only to Administrators and the SYSTEM account; cacls.exe fails with "access denied" unless you're running as elevated/admin.&amp;nbsp; I don't know whether that folder exists on Windows 2000, but the test definitely works on XP, 2003, and Vista.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;[Added 2007-06-27]&amp;nbsp; &lt;/EM&gt;&lt;/STRONG&gt;But as "anonymous" points out in the comments below, FSUTIL works, too, and is a lot easier to type.&lt;/P&gt;
&lt;P&gt;Third:&amp;nbsp; CMD on Vista already prepends the word "Administrator" in the window title if it's running with an enabled Administrators SID in its token, so it's redundant for the autorun to append it.&amp;nbsp; (Not true on XP/2003, of course.)&lt;/P&gt;
&lt;P&gt;Fourth:&amp;nbsp; why not put the current username into the title as well?&amp;nbsp; Good idea!&amp;nbsp; I've added that to my current config.&lt;/P&gt;
&lt;P&gt;So, &lt;EM&gt;&lt;STRONG&gt;now &lt;/STRONG&gt;&lt;/EM&gt;my current CMD autorun looks like this: &lt;EM&gt;&lt;STRONG&gt;[Updated 2007-07-05 with full path to FSUTIL]&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;%windir%\system32\FSUTIL.exe&amp;nbsp;&amp;gt; nul 2&amp;gt; nul &amp;amp;&amp;amp; (color FC &amp;amp; title %USERDOMAIN%\%USERNAME%) || (color 07 &amp;amp; title NONADMIN - %USERDOMAIN%\%USERNAME%)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;One minor point is that unlike the CMD /T option, COLOR sets only the current color --&amp;nbsp;not the default color --&amp;nbsp;for the current window.&amp;nbsp; If you run the COLOR command in that window, it will revert to the default color for the window -- either the user account's default setting or that set by a /T option when the CMD was started.&lt;/P&gt;
&lt;P mce_keep="true"&gt;So... let me go on record by saying that while Microsoft has made a lot of fine products, &lt;A class="" href="http://www.microsoft.com/powershell/" mce_href="http://www.microsoft.com/powershell/"&gt;Windows PowerShell&lt;/A&gt; is the coolest and most revolutionary technology we have shipped in a &lt;EM&gt;very&lt;/EM&gt; long time.&amp;nbsp; (But that's as off-topic as I'm going to get on the subject.)&amp;nbsp; PowerShell is gradually becoming my default command shell, so naturally I'd like to be able to distinguish between elevated and non-elevated instances, both with color and with the window title.&amp;nbsp; Starting with what commenters wrote on my previous post, here's what's in my $profile now:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face="courier new"&gt;
&lt;P mce_keep="true"&gt;function Get-AdminStatus&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $p = New-Object System.Security.Principal.WindowsPrincipal($id)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)&lt;BR&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;$AmIAdmin = Get-AdminStatus&lt;BR&gt;if ( $AmIAdmin )&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.exe /c COLOR FC&lt;BR&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;# Make the window title follow the current directory&lt;BR&gt;function prompt&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '&amp;gt;&amp;gt;' }) + '&amp;gt; '&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( $AmIAdmin )&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $host.UI.RawUI.WindowTitle = "Administrator: " + $(Get-Location)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $host.UI.RawUI.WindowTitle = $(Get-Location)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3529769" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item><item><title>Setting color for *all* CMD shells based on admin/elevation status</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/02/22/setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx</link><pubDate>Fri, 23 Feb 2007 07:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1745576</guid><dc:creator>Aaron Margosis</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/aaron_margosis/comments/1745576.aspx</comments><wfw:commentRss>http://blogs.msdn.com/aaron_margosis/commentrss.aspx?PostID=1745576</wfw:commentRss><description>&lt;P&gt;In my &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2004/06/23/163229.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/06/23/163229.aspx"&gt;RunAs...&lt;/A&gt; and &lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2004/07/24/193721.aspx"&gt;MakeMeAdmin&lt;/A&gt; posts, I recommend making your admin&amp;nbsp;command shells visually different to set them apart from non-admin ones.&amp;nbsp; You can change the default console window color on a per-account basis, but that doesn't help when the same account may be used in both admin and non-admin contexts (such as with Vista's UAC admin-approval mode).&amp;nbsp; You can use the cmd.exe &lt;A class="" href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true" mce_href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true"&gt;/T command-line option&lt;/A&gt;, or&amp;nbsp;its built-in &lt;A class="" href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/color.mspx" mce_href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/color.mspx"&gt;COLOR&lt;/A&gt; command, but it works only if you remember to use it each and every time.&lt;/P&gt;
&lt;P&gt;Here's a way to&amp;nbsp;make the differentiation happen with a one-time, one-line&amp;nbsp;configuration change on your system, that will work on &lt;EM&gt;all&lt;/EM&gt; CMD.EXE shells you run.&amp;nbsp; The idea is to&amp;nbsp;run a&amp;nbsp;non-destructive command that requires admin privileges from&amp;nbsp;a CMD&amp;nbsp;autorun location, test for success and set the console's color accordingly.&amp;nbsp; You can also change the title at the same time.&lt;/P&gt;
&lt;P&gt;This can probably use some refinement.&amp;nbsp; For the non-destructive admin operation on Windows XP/2003, I suggest "&lt;A class="" href="http://technet2.microsoft.com/WindowsServer/en/library/2b9d4ba5-5f75-4dcf-8bf3-9af793909d961033.mspx#BKMK_query" mce_href="http://technet2.microsoft.com/WindowsServer/en/library/2b9d4ba5-5f75-4dcf-8bf3-9af793909d961033.mspx#BKMK_query"&gt;bootcfg /query&lt;/A&gt;";&amp;nbsp;on Windows Vista, I suggest "&lt;A class="" href="http://technet2.microsoft.com/WindowsVista/en/library/08d64d13-4f45-4a05-bd86-c99211a93dd91033.mspx" mce_href="http://technet2.microsoft.com/WindowsVista/en/library/08d64d13-4f45-4a05-bd86-c99211a93dd91033.mspx"&gt;bcdedit /enum&lt;/A&gt;".&amp;nbsp; The autorun location I've been playing with is:&lt;BR&gt;&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [HKLM\Software\Microsoft\Command Processor]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;A class="" href="http://technet2.microsoft.com/WindowsServer/en/library/67385b12-77d3-45f9-852f-4e5178bc9efc1033.mspx?mfr=true" mce_href="http://technet2.microsoft.com/WindowsServer/en/library/67385b12-77d3-45f9-852f-4e5178bc9efc1033.mspx?mfr=true"&gt;AutoRun&lt;/A&gt;" (REG_SZ)&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;The command syntax you can set the "AutoRun" value to for Windows XP/2003 is:&lt;BR&gt;&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bootcfg /query &amp;gt;nul 2&amp;gt;nul &amp;amp;&amp;amp; (color&amp;nbsp;FC &amp;amp;&amp;amp; title ADMIN) || (color 07 &amp;amp;&amp;amp; title NONADMIN)&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;and for Windows Vista, set it to:&lt;BR&gt;&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bcdedit /enum&amp;nbsp;&amp;gt;nul 2&amp;gt;nul &amp;amp;&amp;amp; (color&amp;nbsp;FC &amp;amp;&amp;amp; title ADMIN) || (color 07 &amp;amp;&amp;amp; title NONADMIN)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Any output or error message is redirected to "&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;nul&lt;/STRONG&gt;&lt;/FONT&gt;" so you don't see it.&amp;nbsp; If the command succeeds (&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;&amp;amp;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;), you're running with admin/elevated privileges; the console color will change to bright-red-on-white (&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;FC&lt;/STRONG&gt;&lt;/FONT&gt;) and the title changed to "&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;ADMIN&lt;/STRONG&gt;&lt;/FONT&gt;".&amp;nbsp; If the command fails (&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;||&lt;/STRONG&gt;&lt;/FONT&gt;), the console color will be white-on-black (&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;07&lt;/STRONG&gt;&lt;/FONT&gt;) and the title changed to "&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;NONADMIN&lt;/STRONG&gt;&lt;/FONT&gt;".&amp;nbsp; Feel free to change the colors or titles to suit your taste.&lt;/P&gt;
&lt;P&gt;All that stuff works only for CMD.EXE.&amp;nbsp; For Windows PowerShell, take a look at these:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://www.interact-sw.co.uk/iangblog/2007/02/09/pshdetectelevation"&gt;http://www.interact-sw.co.uk/iangblog/2007/02/09/pshdetectelevation&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.leastprivilege.com/AdminTitleBarForPowerShell.aspx"&gt;http://www.leastprivilege.com/AdminTitleBarForPowerShell.aspx&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Also for PowerShell -- Staffan Gustafsson converted MakeMeAdmin to a PowerShell script:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://groups.archivesat.com/Windows_PowerShell/thread246430.htm"&gt;http://groups.archivesat.com/Windows_PowerShell/thread246430.htm&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;[2007-06-25:&amp;nbsp; Update posted &lt;/EM&gt;&lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/25/follow-up-on-setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx" mce_href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/25/follow-up-on-setting-color-for-all-cmd-shells-based-on-admin-elevation-status.aspx"&gt;&lt;EM&gt;here&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;.]&lt;/EM&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1745576" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Non-admin/default.aspx">Non-admin</category><category domain="http://blogs.msdn.com/aaron_margosis/archive/tags/Vista_2F00_Win7/default.aspx">Vista/Win7</category></item></channel></rss>