<?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>Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx</link><description>Since RunAs.exe won't run a program elevated, is there a way to trigger an elevation prompt from a script?</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3640254</link><pubDate>Sun, 01 Jul 2007 14:10:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3640254</guid><dc:creator>Chris Knight</dc:creator><description>&lt;P&gt;Um, OK.&lt;/P&gt;
&lt;P&gt;So why does my clean install of Vista Business allow me to do a RunAs /user:Administrator cmd.exe that then can delete/write files into the system folders?&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;@Chris:&amp;nbsp; Interesting -- I'll have to check that out.&amp;nbsp; Did you 1) disable UAC, or 2) enable the built-in Administrator account, which is &lt;A class="" href="http://blogs.msdn.com/uac/archive/2006/08/27/727741.aspx"&gt;disabled by default&lt;/A&gt;?&lt;/P&gt;
&lt;P&gt;-- Aaron&lt;/P&gt;&lt;/DIV&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[2007-07-02] &lt;/EM&gt;@Chris:&amp;nbsp; I think I've identified the issue here.&amp;nbsp; By default, "Admin Approval Mode" is disabled for the built-in Administrator account, so any logons for that account run with full admin privileges.&amp;nbsp; So &lt;EM&gt;if you enable that account &lt;/EM&gt;and then use RunAs.exe to start process using that account, it will run elevated and without a UAC elevation prompt.&amp;nbsp; Administrator is disabled by default; I think its primary purpose is for system recovery (e.g., in Safe Mode).&amp;nbsp; If you enable that account, you should also change the security option to enable Admin Approval Mode for that account.&lt;/P&gt;
&lt;P&gt;-- Aaron&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3644129</link><pubDate>Sun, 01 Jul 2007 18:37:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3644129</guid><dc:creator>sean e</dc:creator><description>&lt;p&gt;I do the same as Chris Knight (hey, ex-Beatnik?).&lt;/p&gt;
&lt;p&gt;I have not disabled UAC and I don't think I did anything special to the admin account. &amp;nbsp;My account is a standard user but I leave an admin console open and can do anything in it without UAC prompts (aside from the initial one when first opening the console). &amp;nbsp;Running vista ultimate.&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3644293</link><pubDate>Sun, 01 Jul 2007 18:50:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3644293</guid><dc:creator>sean e</dc:creator><description>&lt;P&gt;Did a little checking... I don't have an account named Administrator, but do have one by another name - so I must have either created it or renamed and enabled the default one.&lt;/P&gt;
&lt;P&gt;Just noticed that I don't explicitly use runas to open my prompt either. &amp;nbsp;I have a shortcut whose properties I modified to run as administrator (properties | shortcut | advanced - it must invoke a runas behind the scenes).&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;@sean e:&amp;nbsp; You're certainly getting an elevation prompt when you do that, right?&amp;nbsp; (Unless you've changed the security policy to elevate without prompting, which is very risky and strongly discouraged.)&lt;/P&gt;
&lt;P&gt;-- Aaron&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3645787</link><pubDate>Sun, 01 Jul 2007 21:09:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3645787</guid><dc:creator>Ramesh</dc:creator><description>&lt;p&gt;Here is another example(.vbs file)&lt;/p&gt;
&lt;p&gt;VBScripts and UAC elevation: &lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.winhelponline.com/articles/185/1/"&gt;http://www.winhelponline.com/articles/185/1/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3646474</link><pubDate>Sun, 01 Jul 2007 21:55:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3646474</guid><dc:creator>Mike Rickard</dc:creator><description>&lt;P&gt;working with Vista to run elevated is more "interesting" than with XP.&lt;/P&gt;
&lt;P&gt;"And RunAs.exe on Windows Vista (RTM, anyway) will not invoke that prompt." - Well it will if the manifest of the program that you're launching &amp;nbsp;shows that it needs to run as administrator.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]:&amp;nbsp; No it doesn't.&amp;nbsp; Try runas /u:adminaccount dfrgui.exe.&amp;nbsp; I get&lt;BR&gt;RUNAS ERROR: Unable to run - dfrgui.exe&lt;BR&gt;740: The requested operation requires elevation.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;In an earlier post I outlined what we do to provide a system for our users to run things elevated, although they logon with ordinary user rights, and we don't give them the local adminstrator password. &lt;A href="http://blogs.msdn.com/aaron_margosis/archive/2005/03/11/394244.aspx#394978" target=_new rel=nofollow&gt;http://blogs.msdn.com/aaron_margosis/archive/2005/03/11/394244.aspx#394978&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For vista we have to change a number of things. As this post outlines you have to use the runas verb with shellexecute to invoke the consent UI and get a process to run with a full token. This complicates matters as not everything has a runas verb. Because we're working from the shell, we're always looking at shell objects. Executables have a runas method, regular shortcuts to executables have a runas method, but "smart shortcuts" (the sort produced for self repairing applications by the MS installer) don't. MMC documents seem to have a runas method.&lt;/P&gt;
&lt;P&gt;So our script will have to look for a runas method, and invoke it if there is one. If there isn't, we'll have to invoke the runas method on another shellexecute utility which launches whatever we want launched. This means that the consent UI refers not to what the user wants to launch, but to our utility, which is why we will invoke the runas verb on the shell object if we can, because then the consent UI will refer correctly. For that reason we'll give MSIs and MSPs a runas method. The way the shell seems to work is to invoke the consent UI (and use the full token) simply because the runas method is what's being invoked. So all you need to do is to copy the open method to a new runas method. (Incidentally, this is a sensible thing to have on an XP box, where you can then use an adminstrative account to install an MSI by simply selecting the runas methos you've created - you'll be prompted for the credentials in the normal way.)&lt;/P&gt;
&lt;P&gt;We still in the process of trying to figure out how to deal with some other "features". As Aaron pointed out recently, you can use this technique to elevate explorer, or at least you seem to be able to do so. However, we are going to have to do some more testing on what happens when you try to elevate explorer, and have other explorer windows already open. If you do this in regualr UAC mode, then it looks as though all your exisiting explorer windows are elevated.&lt;/P&gt;
&lt;P&gt;So it looks as though it should be possible to have a make me admin feature under vista at the cost of some more complicated scripting. For most users looking after their own computer this should be less necessary than it was for XP. As UAC for administrators will be the norm, and because of the way that integrity control works, the range of programs that work when installed via the consent UI by an administrative user with a split token, but don't work when installed by a different administrative account should be much reduced. I'd still advocate using an account with no special privileges for operating a vista system. One of the bizarre consequences of UAC is that some programs which operate correctly, but with some limitations for unprivileged users will prompt for elevation when you don't want this. e.g. regedit - Unless I actually want to edit the machine registry, which isn't very often, I'd much rather open regedit with no special privileges to edit my own profile, and view the machine registry.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]:&amp;nbsp; Some apps are configured to run in the current context (asInvoker), some are configured to require elevation (requireAdministrator), and some -- including regedit.exe and mmc.exe -- are configured to require elevation if the user is an admin running with a filtered token (highestAvailable).&amp;nbsp; IMHO, the marking of regedit and mmc as highestAvailable is an unfortunate but understandable compromise for the Vista RTM timeframe.&amp;nbsp; Maybe a future blog post. :-)&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Our last problem, how to deal with UAC style elevation prompts forced by hardware changes seems to be insoluble. Once the elevation prompt is on screen you can't do anything except supply credentials or cancel. You can't add yourself on the fly to the adminstrators group until after you've cancelled. So the best we'll be able to do is to try to explain how to cancel, add on the fly, and then force the elevate prompt back again. This will require them to read the documentation we provide. Our experience is that most of our users regard documentation as an indication of a poor system: if they can't get it to work without documentation then we should have designed it properly in the first place!&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]:&amp;nbsp; Good luck.&amp;nbsp; The design goals of Windows Vista definitely assume that either the user is trusted with system administration privileges, or not.&amp;nbsp; We have found that most forms of "partial administrative capabilities" such as "Power Users" usually end up including an inexorable path to full administrative capabilities.&amp;nbsp; That's why Power Users has been deprecated in Windows Vista, and &lt;/EM&gt;&lt;A class="" href="http://blogs.msdn.com/aaron_margosis/archive/2007/06/29/faq-why-can-t-i-bypass-the-uac-prompt.aspx"&gt;&lt;EM&gt;why we didn't include any kind of setuid or sudo functionality&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3660122</link><pubDate>Mon, 02 Jul 2007 17:36:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3660122</guid><dc:creator>sean e</dc:creator><description>&lt;P&gt;&amp;gt;@sean e: &amp;nbsp;You're certainly getting an elevation &amp;gt;prompt when you do that, right?&lt;/P&gt;
&lt;P&gt;Yes, I get the prompt when I open the console. &amp;nbsp;After that initial one, I'm good for doing anything without further prompts.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;@sean e:&amp;nbsp; As expected.&amp;nbsp; If an elevated program starts another program, the new program will also run elevated.&lt;/P&gt;
&lt;P&gt;BTW, what you're doing is not invoking RUNAS.EXE, the console utility program.&lt;/P&gt;
&lt;P&gt;-- Aaron&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3661358</link><pubDate>Mon, 02 Jul 2007 19:16:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3661358</guid><dc:creator>Rod Trent at myITforum.com</dc:creator><description>&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx"&gt;http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>How to trigger UAC elevation from a script</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3663033</link><pubDate>Mon, 02 Jul 2007 22:31:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3663033</guid><dc:creator>InstallSite Blog</dc:creator><description>&lt;p&gt;If you need to run command with full administrator permissions in Windows Vista, you could use the elevated&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3665604</link><pubDate>Tue, 03 Jul 2007 03:38:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3665604</guid><dc:creator>rwx---rwx</dc:creator><description>&lt;P&gt;&amp;gt; Administrator is disabled by default [...]&lt;/P&gt;
&lt;P&gt;&amp;gt; If you enable that account, you should also&lt;/P&gt;
&lt;P&gt;&amp;gt; change the security option to enable Admin&lt;/P&gt;
&lt;P&gt;&amp;gt; Approval Mode for that account.&lt;/P&gt;
&lt;P&gt;I think that's a good idea. &amp;nbsp;But you have a better idea:&lt;/P&gt;
&lt;P&gt;[For other administrative accounts]&lt;/P&gt;
&lt;P&gt;&amp;gt; (Unless you've changed the security policy to&lt;/P&gt;
&lt;P&gt;&amp;gt; elevate without prompting, which is very risky&lt;/P&gt;
&lt;P&gt;&amp;gt; and strongly discouraged.)&lt;/P&gt;
&lt;P&gt;I think that's a very good idea. &amp;nbsp;I think it should apply to the built-in Administrator account too, for exactly the same reason. &amp;nbsp;There should not be a default which changes the built-in Administrator account to elevate without prompting. &amp;nbsp;The default should put the same Admin Approval Mode on that account as it does on other administrative accounts, because any deviation is risky and strongly discouraged.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis] The default is that admin-approval mode (AAM) is disabled for the built-in Administrator account, but that the built-in Administrator account itself&amp;nbsp;is also disabled.&amp;nbsp; Its purpose (as I understand it) is to serve in emergencies such as system recovery, at which point you presumably wouldn't want AAM to be in the way.&amp;nbsp; If you intend to use the built-in Administrator account for other purposes and enable the account, you should probably change its AAM setting at the same time.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;gt; We have found that most forms of "partial&lt;/P&gt;
&lt;P&gt;&amp;gt; administrative capabilities" such as "Power&lt;/P&gt;
&lt;P&gt;&amp;gt; Users" usually end up including an inexorable&lt;/P&gt;
&lt;P&gt;&amp;gt; path to full administrative capabilities.&lt;/P&gt;
&lt;P&gt;Yes. &amp;nbsp;Any administrator who wants to be administrator and intentionally sets out to be administrator should be allowed to be administrator. &amp;nbsp;But some of us peasants occasionally make typos or (more commonly for some of us) accidentally hit a mouse button while moving the mouse, causing unwanted operations to occur. &amp;nbsp;So some of us would be glad to be administrators only when we want to be, and be power users the rest of the time. &amp;nbsp;The prompts do help a bit, but I think that was no reason to get rid of power users.&lt;/P&gt;
&lt;P&gt;In old days, I used to set tape reels to r--r--r-- except when intending to write to them. &amp;nbsp;I still sometimes set floppy disks to r-xr-xr-x except when intending to write to them. &amp;nbsp;I wish I could mount disk partitions as r-xr-xr-x.[*] &amp;nbsp;Sure, as a power user I have the power to change the settings at will, but at least I won't usually do that accidentally, and at least it means I'd have to make at least two accidental mistakes in a row before doing serious damage. &amp;nbsp;Power users are useful.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis] I'm not sure that we're talking about the same thing.&amp;nbsp; I'm referring to Power Users, the "admin-lite" group that's been present since NT 3.1.&amp;nbsp; It was intended as a middle ground, more powerful than Users, but less so than Administrators.&amp;nbsp; However, that ground proved to be untenable, as the access that was granted to Power Users allowed it to elevate to full system control.&amp;nbsp; That's why it's been deprecated.&amp;nbsp; For reference, see &lt;/EM&gt;&lt;A class="" href="http://support.microsoft.com/Default.aspx?kbid=825069"&gt;&lt;EM&gt;this KB article&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;, &lt;/EM&gt;&lt;A class="" href="http://blogs.technet.com/jesper_johansson/archive/2006/03/12/421870.aspx"&gt;&lt;EM&gt;Jesper's blog post&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;, and &lt;/EM&gt;&lt;A class="" href="http://blogs.technet.com/markrussinovich/archive/2006/05/01/the-power-in-power-users.aspx"&gt;&lt;EM&gt;Mark Russinovich's blog post&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;[* Even in Linux I wish I could mount disk partitions as r-xr-xr-x. &amp;nbsp;Drivers disobey that setting when replaying journals, and I wish I could stop them. &amp;nbsp;But this is off-topic, sorry.]&lt;/P&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3694284</link><pubDate>Thu, 05 Jul 2007 00:44:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3694284</guid><dc:creator>Per &amp;#216;stergaard</dc:creator><description>&lt;P&gt;I made a PowerShell version of the JS script. See &lt;A href="http://msgoodies.blogspot.com/2007/07/powershell-start-elevatedprocess.html" target=_new rel=nofollow&gt;http://msgoodies.blogspot.com/2007/07/powershell-start-elevatedprocess.html&lt;/A&gt;&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp;&amp;nbsp;As I said &lt;/EM&gt;&lt;A class="" href="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"&gt;&lt;EM&gt;here&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;, Windows PowerShell is the coolest and most revolutionary technology we have shipped in a very long time.&amp;nbsp; Thanks for providing more evidence, Per! :-)&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3696246</link><pubDate>Thu, 05 Jul 2007 05:03:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3696246</guid><dc:creator>rwx---rwx</dc:creator><description>&lt;P&gt;"Administrator" account&lt;/P&gt;
&lt;P&gt;&amp;gt; Its purpose (as I understand it) is to serve&lt;/P&gt;
&lt;P&gt;&amp;gt; in emergencies such as system recovery, at&lt;/P&gt;
&lt;P&gt;&amp;gt; which point you presumably wouldn't want AAM&lt;/P&gt;
&lt;P&gt;&amp;gt; to be in the way.&lt;/P&gt;
&lt;P&gt;OK, I see the point.&lt;/P&gt;
&lt;P&gt;"Power users" (admin-capable but not by default)&lt;/P&gt;
&lt;P&gt;&amp;gt; I'm not sure that we're talking about the&lt;/P&gt;
&lt;P&gt;&amp;gt; same thing. &amp;nbsp;I'm referring to Power Users,&lt;/P&gt;
&lt;P&gt;We are. &amp;nbsp;We agree that power users have the capability to become admins. &amp;nbsp;You think there's no purpose in letting admin-capable people run as power users until they deliberately decide to be admins. &amp;nbsp;I think there is a purpose, and I tried to explain why. &amp;nbsp;Vista's prompts provide some of the same protections, because sometimes someone who fat-fingers a mouse key or keyboard key might get a second chance to avoid doing what they didn't intend to so. &amp;nbsp;The power users group was a more powerful way to provide the same protections. &amp;nbsp;It's like having the SETPRIV bit or knowing the root password, you deliberately enable privileges when you need them but you don't enable them otherwise. &amp;nbsp;Oops sorry, s/you/I/.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; Power Users (as it existed on XP and earlier) provides no such&amp;nbsp;protections.&amp;nbsp; Running as Power User was tantamount to running as admin.&amp;nbsp; There were tons of things you could do to damage the system and/or other users.&amp;nbsp; More importantly, malware that runs in your session could immediately take over the entire system.&amp;nbsp; The whole idea of UAC is for end users (including people who administer their own systems) to have only the power they typically need for computer use -- in which the system and other users cannot be touched.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3716417</link><pubDate>Fri, 06 Jul 2007 03:07:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3716417</guid><dc:creator>rwx---rwx</dc:creator><description>&lt;p&gt;&amp;gt; Running as Power User was tantamount to&lt;/p&gt;
&lt;p&gt;&amp;gt; running as admin.&lt;/p&gt;
&lt;p&gt;Already known and agreed.&lt;/p&gt;
&lt;p&gt;&amp;gt; More importantly, malware that runs in your&lt;/p&gt;
&lt;p&gt;&amp;gt; session could immediately take over the&lt;/p&gt;
&lt;p&gt;&amp;gt; entire system.&lt;/p&gt;
&lt;p&gt;OK, you mean that vulnerabilities in the capabilities of Power Users made it possible for malware to enable itself to do the same things without any further interaction with the user. &amp;nbsp;OK, that's dangerous.&lt;/p&gt;
&lt;p&gt;I thought the idea behind power users (the ability to be admin when desired but not automatically being admin when not desired) was a good idea. &amp;nbsp;But now this reminds me of our other discussion:&lt;/p&gt;
&lt;p&gt;Now I notice that if Vista had a real MakeMeAdmin then there wouldn't be much difference between standard users and power users. &amp;nbsp;The ability to temporarily add their own account to the administrators group would work for standard users as well as for power users. &amp;nbsp;So theoretically maybe there's no need for power users, we just need MakeMeAdmin.&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3749124</link><pubDate>Sat, 07 Jul 2007 21:37:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3749124</guid><dc:creator>Mike Rickard</dc:creator><description>&lt;p&gt;I said: &amp;quot;And RunAs.exe on Windows Vista (RTM, anyway) will not invoke that prompt.&amp;quot; - Well it will if the manifest of the program that you're launching &amp;nbsp;shows that it needs to run as administrator.&lt;/p&gt;
&lt;p&gt;[Aaron Margosis]: &amp;nbsp;No it doesn't. &amp;nbsp;Try runas /u:adminaccount dfrgui.exe. &amp;nbsp;I get&lt;/p&gt;
&lt;p&gt;RUNAS ERROR: Unable to run - dfrgui.exe&lt;/p&gt;
&lt;p&gt;740: The requested operation requires elevation.&lt;/p&gt;
&lt;p&gt;Aaron is quite right, and I'm an idiot for not checking why I came to that conclusion. why I did is just interesting enough to report.&lt;/p&gt;
&lt;p&gt;What I had been doing was checking my privilege elevation utility. (This is a MakeMeAdmin kind of thing.) When I used this I saw the behaviour I claimed for runas: Only programs marked to require administrative rights were elevated. The reason is quite simple: After doing the necessary fiddling with group memberships the utility invokes runas like this:&lt;/p&gt;
&lt;p&gt;runas /u:adminaccount &amp;quot;shelexec dfrgui.exe&amp;quot;&lt;/p&gt;
&lt;p&gt;where shelexec is a simple command line program that invokes the shelexec function of the shell to launch something. We used this because it would launch non-executables such as MSIs and also shortcuts: the sort of things that you find via the GUI. We didn't supply a verb to the function, so that it used the default verb. i.e. the verb that double-clicking would invoke. Hence the behaviour we saw was exactly the same as double-clicking on something: if it's marked as requiring elevation and you have the right to do this, you get an elevation prompt, if it isn't so marked it is simply launched without extra rights.&lt;/p&gt;
&lt;p&gt;The only effective difference from the script that Aaron uses is we used the default verb, his script uses the Runas verb.&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#3790617</link><pubDate>Tue, 10 Jul 2007 05:19:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3790617</guid><dc:creator>rws---rwx (idiot with an idiot system)</dc:creator><description>&lt;P&gt;&amp;gt; Running as Power User was tantamount to&lt;/P&gt;
&lt;P&gt;&amp;gt; running as admin.&lt;/P&gt;
&lt;P&gt;Already known and agreed, and now being revisited.&lt;/P&gt;
&lt;P&gt;Running as Power User was tantamount to running as Local System. &amp;nbsp;Running as Admin was tantamount to running as Local System. &amp;nbsp;Under Vista, running as Admin is *still* tantamount to running as Local System.&lt;/P&gt;
&lt;P&gt;Now please bear with me. &amp;nbsp;Sometimes I'm an Admin, therefore sometimes I'm an Idiot (already known and agreed). &amp;nbsp;Now I've just verified that even in Vista I can sometimes be Local System, and therefore Local System is sometimes an Idiot. &amp;nbsp;So please patiently explain this to me:&lt;/P&gt;
&lt;P&gt;Why didn't Administrators disappear along with Power Users? &amp;nbsp;Why aren't we running as Local System with UAC?&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; What would be the value of that?&amp;nbsp; Note that with Administrators you still have your own account, your own settings, preferences, etc.&amp;nbsp; LocalSystem was never designed to be used as an interactive logon.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;(Off-topic tangent: &amp;nbsp;why is cron setuid to Administrator instead of setuid to Local System?)&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; Is that how "cron" is default-configured in the Vista Subsystem for UNIX-based applications? &lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>UAC Elevation Prompt Behaviour on All  Vista Editions</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#4168000</link><pubDate>Wed, 01 Aug 2007 16:27:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4168000</guid><dc:creator>Gayle</dc:creator><description>&lt;P&gt;2 UAC Settings have been documented as&lt;/P&gt;
&lt;P&gt;1. UAC:Behaviour of the elevation prompt for standard users&lt;/P&gt;
&lt;P&gt;Default: Prompt for credentials (home) / Automatically deny elevation requests (enterprise)&lt;/P&gt;
&lt;P&gt;2. User Account Control: Detect application installations and prompt for elevation&lt;/P&gt;
&lt;P&gt;Default: Enabled (home) / Disabled (enterprise)&lt;/P&gt;
&lt;P&gt;Where can I get details for the other editions?&lt;/P&gt;
&lt;DIV class=ajmReply&gt;&lt;I&gt;
&lt;P&gt;[Aaron Margosis] Gayle, what's the source of your references?&lt;/P&gt;
&lt;P&gt;If I'm not mistaken, the default, out-of-the-box settings are the same for all Vista editions.&amp;nbsp; The security guidance for enterprise-managed systems is for same-desktop elevation to be blocked for standard users.&amp;nbsp; In this context, "home" and "enterprise" aren't named editions as much as they are management contexts.&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;&lt;/I&gt;&lt;/DIV&gt;</description></item><item><title>UAC Elevation Prompt Behaviour on All Vista Editions</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#4187437</link><pubDate>Thu, 02 Aug 2007 15:32:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4187437</guid><dc:creator>Gayle</dc:creator><description>&lt;P&gt;Besides seeing the default settings for both UAC Policies on the Explain tab of the policies' Properties in Group Policy Editor, its also at this link :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://technet2.microsoft.com/WindowsVista/en/library/00d04415-2b2f-422c-b70e-b18ff918c2811033.mspx" target=_new rel=nofollow&gt;http://technet2.microsoft.com/WindowsVista/en/library/00d04415-2b2f-422c-b70e-b18ff918c2811033.mspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;as follows -&lt;/P&gt;
&lt;P&gt;User Account Control: Behavior of the elevation prompt for standard users &lt;/P&gt;
&lt;P&gt;• Home: Prompt for credentials&lt;/P&gt;
&lt;P&gt;• Enterprise: No prompt&lt;/P&gt;
&lt;P&gt;&amp;amp; this link for both Policies, WHICH IS CORRECT?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://technet.microsoft.com/en-us/windowsvista/aa905117.aspx" target=_new rel=nofollow&gt;http://technet.microsoft.com/en-us/windowsvista/aa905117.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;1. User Account Control: Behavior of the elevation prompt for standard users&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Home: Prompt for credentials&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Enterprise: No prompt&lt;/P&gt;
&lt;P&gt;2. User Account Control: Detect application installations and prompt for elevation&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Home: Enabled&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Enterprise: Disabled&lt;/P&gt;
&lt;P&gt;WRT your reply,&lt;/P&gt;
&lt;P&gt;How is Vista capable of detecting which &amp;nbsp;management contexts applies at any point in time to apply the defaults in case of home &amp;amp; enterprise?&lt;/P&gt;
&lt;P&gt;Please clarify what management contexts means &amp;amp; how the defaults get applied.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; Gayle:&amp;nbsp; thanks for pointing those out.&amp;nbsp; That documentation is all incorrect.&amp;nbsp; The out-of-the-box defaults are the same for all editions of Windows Vista.&amp;nbsp; For "Behavior of the elevation prompt for standard users" it's "Prompt for credentials", and for "Detect application installations..." it's "Enabled".&amp;nbsp; Sorry for the confusion.&amp;nbsp; I've alerted the appropriate people to the errors.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#4187605</link><pubDate>Thu, 02 Aug 2007 15:51:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4187605</guid><dc:creator>Gayle</dc:creator><description>&lt;p&gt;Is there a way to detect for a machine that has been upgraded from XP to Vista - &amp;nbsp;the exceptional case in which Admin Approval Mode for the Built-in Administrator is enabled by default.&lt;/p&gt;
&lt;p&gt;Is it possible to get the effective setting for this UAC policy - if it has not been explicitly configured ?&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#4267712</link><pubDate>Tue, 07 Aug 2007 02:09:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4267712</guid><dc:creator>Jonathan</dc:creator><description>&lt;p&gt;Gayle: &amp;nbsp;I chatted with Aaron about the question on this policy and he suggested that I reply to the post. &amp;nbsp;That policy is picked up dynamically, so you could technically just look at this reg value:&lt;/p&gt;
&lt;p&gt;HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\FilterAdministratorToken&lt;/p&gt;
&lt;p&gt;to see if it's set to non-zero (i.e., turned on); if it's 0 or missing, it's turned off.&lt;/p&gt;
&lt;p&gt;That said, all the major caveats apply here that this is an implementation detail that's certain to change or be removed in the future.&lt;/p&gt;
&lt;p&gt;In theory, you shouldn't even need to check for it, since things will &amp;quot;just work&amp;quot; if your code is already running as a standard user and handling &amp;quot;over the shoulder&amp;quot; elevation (i.e., starting from a standard user account and elevating with a different user).&lt;/p&gt;
&lt;p&gt;--Jonathan&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#4303165</link><pubDate>Thu, 09 Aug 2007 05:51:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4303165</guid><dc:creator>Gayle</dc:creator><description>&lt;p&gt;In current Editions of Vista , are the UAC registry values present by default ? i.e. when it shows as Not Configured in the Group Policy Editor&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#4321954</link><pubDate>Fri, 10 Aug 2007 16:06:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4321954</guid><dc:creator>Jonathan</dc:creator><description>&lt;p&gt;With the exception of FilterAdministratorToken, I'd expect them all to be present by default.&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#5264156</link><pubDate>Wed, 03 Oct 2007 18:46:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5264156</guid><dc:creator>Peter Griessl</dc:creator><description>&lt;P&gt;"Drop elevation"?&lt;/P&gt;
&lt;P&gt;Is there any way to drop/reduce the elevation back to normal level inside an elevated script?&lt;/P&gt;
&lt;P&gt;1. elevate mysuperscript.bat&lt;/P&gt;
&lt;P&gt;2. mysuperscript.bat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;...execute elevated commands&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;drop elevation&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;...execute standard commands&lt;/P&gt;
&lt;P&gt;Thanks for any hints!&lt;/P&gt;
&lt;P&gt;Peter Griessl, &lt;A href="mailto:griessl@ihs.ac.at"&gt;griessl@ihs.ac.at&lt;/A&gt;&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis] Not really.&amp;nbsp; It's not safe to assume that the desktop user and the elevated context represent the same user.&amp;nbsp; Elevation may involve a different user's credentials.&amp;nbsp; I haven't tried this with script yet, but I would try to create a script that runs non-elevated, launches something elevated as needed (will be in a separate process), then performs the non-elevated operations.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#6755954</link><pubDate>Thu, 13 Dec 2007 09:25:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6755954</guid><dc:creator>stefan kanthak</dc:creator><description>&lt;p&gt;Aaron:&lt;/p&gt;
&lt;p&gt;have you ever tested the script with pathnames and arguments containing blanks?&lt;/p&gt;
&lt;p&gt;Replace '= WScript.Arguments()' with '= &amp;quot;\&amp;quot;&amp;quot; + WScript.Arguments() + &amp;quot;\&amp;quot;&amp;quot;' when this should work right!&lt;/p&gt;
</description></item><item><title>Vista: Administrator Script on Command Line</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#6768365</link><pubDate>Fri, 14 Dec 2007 10:20:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6768365</guid><dc:creator>JOMYUT.NET</dc:creator><description>&lt;p&gt;When you are on Microsoft Windows Vista Platform. It is hard to create a script that use privilage command. One way is by use the command &amp;amp;quot;Runas&amp;amp;quot; as followC:\&amp;amp;gt; Runas /user:Administrator cmdHowever, the above command will ask for Administrato&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#7314091</link><pubDate>Wed, 30 Jan 2008 01:44:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7314091</guid><dc:creator>nathan carnal</dc:creator><description>&lt;P&gt;My application sets a value in HKLM\Software\Microsoft\Windows\CurrentVersion\Run to add it to the startup. &amp;nbsp;In Vista, I receive access is denied. &amp;nbsp;What is the easiest way to correct this issue? &amp;nbsp;My application does not require admin priviledges except for this option (user can turn this feature on/off), but I do not want to prompt for elevation if it is not required. &amp;nbsp;Is this possible and if so what would you recommend to solve this? &amp;nbsp;Any help would be greatly appreciated. &amp;nbsp;Thanks ahead of time.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; Does it need to be in HKLM?&amp;nbsp; If you put it in the equivalent key under HKCU, then it will launch every time that user logs on, and you won't get access denied when you set or clear the value.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#7327189</link><pubDate>Wed, 30 Jan 2008 17:25:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7327189</guid><dc:creator>nathan carnal</dc:creator><description>&lt;P&gt;Thanks for the quick response. &amp;nbsp;I would really like to make the changes to the HKLM b/c the application will run in a classroom setting and students will be logging on/off. &amp;nbsp;Any ideas?&lt;/P&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; Generally speaking, non-admin users shouldn't be able to make configuration changes that affect other users.&amp;nbsp; Giving users the ability to change that key, in particular, is very dangerous.&amp;nbsp; I'd recommend just allowing individual users to change the settings for themselves, or just add it to HKLM as part of installation and don't give the users the option to turn it off.&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#7900901</link><pubDate>Tue, 26 Feb 2008 11:58:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7900901</guid><dc:creator>Coolie</dc:creator><description>&lt;p&gt;I am elevating a windows installer setup.exe. The script runs fine on vista. On XP I either get '&amp;lt;full path&amp;gt;\setup.ini' not found or, in a directory with a shorter path I get &amp;quot;The windows installer service could not be accessed....&amp;quot;&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#8074939</link><pubDate>Thu, 06 Mar 2008 20:52:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8074939</guid><dc:creator>QuietTode</dc:creator><description>&lt;p&gt;In my environment, all the admins are set to 'Prompt for Consent'. The leads to 740 errors with the RunAs command. To work around it, I created a shortcut to always run as admin and used the runas /netonly switch:&lt;/p&gt;
&lt;p&gt;C:\Windows\System32\runas.exe /netonly /user:domain\username &amp;quot;mmc c:\windows\system32\dsa.msc&amp;quot;&lt;/p&gt;
&lt;p&gt;This works with the netonly switch, but not without.&lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#8233571</link><pubDate>Sat, 15 Mar 2008 19:59:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8233571</guid><dc:creator>Nicholas Wourms</dc:creator><description>&lt;P&gt;What is your opinion of this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://technet.microsoft.com/en-us/magazine/cc162321.aspx" target=_new rel=nofollow&gt;http://technet.microsoft.com/en-us/magazine/cc162321.aspx&lt;/A&gt;&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; Yes, I referenced it in the italicized first line (added the day after I first posted).&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#8289754</link><pubDate>Mon, 17 Mar 2008 18:00:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8289754</guid><dc:creator>Colin</dc:creator><description>&lt;p&gt;I'm logged in as a local admin but I run MMC windows (AD users and computers, WSUS management etc) as a separate user. &amp;nbsp;This method is fine for non admin users but the only way I can find so far to run as a different user is to change User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode to prompt for credentials which some what defeats the point of being a local admin.&lt;/p&gt;
&lt;p&gt;Thoughts? &amp;nbsp; &amp;nbsp; &lt;/p&gt;
</description></item><item><title>re: Scripting Elevation on Vista</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#9005143</link><pubDate>Sat, 18 Oct 2008 20:43:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9005143</guid><dc:creator>erich</dc:creator><description>&lt;p&gt;i am using robocopy.exe (provided with the Microsoft Resource Kit Tools) to backup my system. on win xp i used runas to start a command line (cmd.exe) with a user in the &amp;quot;Backup Operators&amp;quot; group to (in turn) start robocopy.exe (as backup operator) to backup the system.&lt;/p&gt;
&lt;p&gt;is there any way to specify a particular user that is a non-admin (namely a backup operator) in the UAC prompt or with the elevate.js script mentioned in this post?&lt;/p&gt;
&lt;p&gt;in other words, how can i get this functionality with vista:&lt;/p&gt;
&lt;p&gt;runas /user:bo cmd.exe&lt;/p&gt;
&lt;p&gt;wehere the user &amp;quot;bo&amp;quot; is merely within the &amp;quot;Backup Operators&amp;quot; not the &amp;quot;Administrators&amp;quot; group? is there a way to add the &amp;quot;bo&amp;quot; user to the UAC prompt or to specify when using the elevate.js script?&lt;/p&gt;
</description></item><item><title>*detecting* elevation context</title><link>http://blogs.msdn.com/aaron_margosis/archive/2007/07/01/scripting-elevation-on-vista.aspx#9015444</link><pubDate>Sat, 25 Oct 2008 03:01:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9015444</guid><dc:creator>quux</dc:creator><description>&lt;P&gt;I'm writing a vbscript which will ultimately run on many versions of Windows - XP, 2003, Vista, 2008 - maybe even 2000. Within the script are a few things that will require elevated access - but they are conditional events. &lt;/P&gt;
&lt;P&gt;What I need is a way to *detect* whether the script is currently in an elevated context or not, so that the script can intelligently decide whether to attempt elevated actions.&lt;/P&gt;
&lt;P&gt;After much experimentation and searching, I have yet to find a solid method of doing this, that doesn't require 3rdparty utilities which may or may not be present.&lt;/P&gt;
&lt;P&gt;Any thoughts, Aaron?&lt;/P&gt;
&lt;DIV class=ajmReply&gt;
&lt;P&gt;&lt;EM&gt;[Aaron Margosis]&amp;nbsp; If the&amp;nbsp;question is "am I running with full admin rights", then how about just trying to do something benign that requires full admin rights?&amp;nbsp; How about this:&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=Courier&gt;
&lt;P&gt;option explicit&lt;/P&gt;
&lt;P&gt;Function IsAdmin()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dim fso, sFilename&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Randomize&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set fso = WScript.CreateObject("Scripting.FileSystemObject")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;on error resume next&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sFileName = "C:\temporary-test-file-" &amp;amp; Rnd()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fso.CreateTextFile sFileName&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if err.number = 0 then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fso.DeleteFile sFileName&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IsAdmin = True&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IsAdmin = False&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end if&lt;BR&gt;End Function&lt;/P&gt;
&lt;P&gt;If IsAdmin Then&lt;BR&gt;&amp;nbsp;WScript.Echo "Running as admin"&lt;BR&gt;Else&lt;BR&gt;&amp;nbsp;WScript.Echo "Not running as admin"&lt;BR&gt;End if&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;This should work on all the Windows versions you mentioned except Windows 2000 -- non-admins are allowed to create files in C:\ on Windows 2000, but not on any version of Windows since.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;HTH&lt;/EM&gt;&lt;/P&gt;&lt;/DIV&gt;</description></item></channel></rss>