<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Using UAC with C# &#8211; Part 1</title> <atom:link href="http://victorhurdugaci.com/using-uac-with-c-part-1/feed/" rel="self" type="application/rss+xml" /><link>http://victorhurdugaci.com/using-uac-with-c-part-1/</link> <description>Victor Hurdugaci&#039;s playground</description> <lastBuildDate>Wed, 09 May 2012 17:30:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item><title>By: Ray</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-3/#comment-2800</link> <dc:creator>Ray</dc:creator> <pubDate>Sun, 01 Apr 2012 14:23:50 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2800</guid> <description>Thank you very much!
This is very useful!</description> <content:encoded><![CDATA[<p>Thank you very much!<br
/> This is very useful!</p> ]]></content:encoded> </item> <item><title>By: Lawrence Sweet</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-3/#comment-2753</link> <dc:creator>Lawrence Sweet</dc:creator> <pubDate>Thu, 01 Mar 2012 23:04:51 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2753</guid> <description>Anthony,
You might try &quot;setacl.exe&quot; as part of your installation. You can grant users and/or groups specific rights to work with specific windows services.
Also, &quot;local system account&quot; privileges might be required to start your own service...(?). Better double check that one :)
Best Wishes</description> <content:encoded><![CDATA[<p>Anthony,</p><p>You might try &#8220;setacl.exe&#8221; as part of your installation. You can grant users and/or groups specific rights to work with specific windows services.</p><p>Also, &#8220;local system account&#8221; privileges might be required to start your own service&#8230;(?). Better double check that one :)</p><p>Best Wishes</p> ]]></content:encoded> </item> <item><title>By: UAC in .NET Anwendungen - seeseekey.net</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-3/#comment-2486</link> <dc:creator>UAC in .NET Anwendungen - seeseekey.net</dc:creator> <pubDate>Sun, 20 Nov 2011 08:49:35 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2486</guid> <description>[...] Infor­ma­tio­nen gibt es unter: http://www.vbarchiv.net/workshop/workshop_115.html http://victorhurdugaci.com/using-uac-with-c-part-1/ http://victorhurdugaci.com/using-uac-with-c-part-2/ [...]</description> <content:encoded><![CDATA[<p>[...] Infor­ma­tio­nen gibt es unter: <a
href="http://www.vbarchiv.net/workshop/workshop_115.html" rel="nofollow">http://www.vbarchiv.net/workshop/workshop_115.html</a> <a
href="http://victorhurdugaci.com/using-uac-with-c-part-1/" rel="nofollow">http://victorhurdugaci.com/using-uac-with-c-part-1/</a> <a
href="http://victorhurdugaci.com/using-uac-with-c-part-2/" rel="nofollow">http://victorhurdugaci.com/using-uac-with-c-part-2/</a> [...]</p> ]]></content:encoded> </item> <item><title>By: Andre</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-3/#comment-2399</link> <dc:creator>Andre</dc:creator> <pubDate>Tue, 31 May 2011 12:01:30 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2399</guid> <description>Thanks for your code but I&#039;ve a problem using ist with Windows 7 ...
I run a progress using like described:
ProcessStartInfo info = new ProcessStartInfo(MyApp, cmd);
info.Verb = &quot;runas&quot;;
Process.Start(info);
MyApp try than to change the rights of a file:
FileSecurity fnew = File.GetAccessControl(target);
FileSecurity fold = File.GetAccessControl(oldFile);
AuthorizationRuleCollection arc = fold.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
System.Collections.IEnumerator ienu = arc.GetEnumerator();
while (ienu.MoveNext())
{
FileSystemAccessRule ar = (FileSystemAccessRule)ienu.Current;
if (ar.IdentityReference != null)
{
fnew.PurgeAccessRules(ar.IdentityReference);
fnew.AddAccessRule(new FileSystemAccessRule(ar.IdentityReference, ar.FileSystemRights, ar.AccessControlType));
}
}
fnew.SetOwner(fold.GetOwner(typeof(System.Security.Principal.NTAccount)));
fnew.SetAuditRuleProtection(false, true);
File.SetAccessControl(target, fnew);
Now I get the error &quot;SeSecurityPrivilege is missing&quot; with Windows 7.
Any idea how I can use my code also with W7?</description> <content:encoded><![CDATA[<p>Thanks for your code but I&#8217;ve a problem using ist with Windows 7 &#8230;<br
/> I run a progress using like described:<br
/> ProcessStartInfo info = new ProcessStartInfo(MyApp, cmd);<br
/> info.Verb = &#8220;runas&#8221;;<br
/> Process.Start(info);</p><p>MyApp try than to change the rights of a file:<br
/> FileSecurity fnew = File.GetAccessControl(target);<br
/> FileSecurity fold = File.GetAccessControl(oldFile);<br
/> AuthorizationRuleCollection arc = fold.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));<br
/> System.Collections.IEnumerator ienu = arc.GetEnumerator();<br
/> while (ienu.MoveNext())<br
/> {<br
/> FileSystemAccessRule ar = (FileSystemAccessRule)ienu.Current;<br
/> if (ar.IdentityReference != null)<br
/> {<br
/> fnew.PurgeAccessRules(ar.IdentityReference);<br
/> fnew.AddAccessRule(new FileSystemAccessRule(ar.IdentityReference, ar.FileSystemRights, ar.AccessControlType));<br
/> }<br
/> }<br
/> fnew.SetOwner(fold.GetOwner(typeof(System.Security.Principal.NTAccount)));<br
/> fnew.SetAuditRuleProtection(false, true);<br
/> File.SetAccessControl(target, fnew);</p><p>Now I get the error &#8220;SeSecurityPrivilege is missing&#8221; with Windows 7.<br
/> Any idea how I can use my code also with W7?</p> ]]></content:encoded> </item> <item><title>By: Anthony</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-2/#comment-2394</link> <dc:creator>Anthony</dc:creator> <pubDate>Mon, 16 May 2011 05:05:43 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2394</guid> <description>Much like stefan&#039;s comment above, i have a situation where i need to elevate a process created in C#. Specifically i have to start/stop/restart a windows service. I can query the service just fine but actually getting the service to do something keeps on throwing an &quot;Access is denied&quot; exception. So far i&#039;ve tried:
-changing the manifest file so that permission level is set to &quot;highestAvailable&quot; (still was deined access)
-creating my own service that would in turn restart the service i was originally targetting (this new service was then denied access to the original service - or so it seems.  furhtermore i was denied access to it.)
-trying to create my own token? (i wouldn&#039;t consider myself completely new to c# but i&#039;ve never really dealt with the UAC security model and i&#039;m kind of flying blind here)
Ultimately i&#039;ve settled on hijacking the task scheduler to run the my program in an elevated state, though this seems like an inelegant way to do things.
I get the fact that this is the very thing UAC is put in place for, namely the prevention of running potentially dangerous code without the prompting the user first.
In order to give you some background as to why i&#039;m trying to suppress the dialog. My laptop has an illuminated keyboard but no button that directly turns it off/on. You have to drill down through a settings app and manually turn illumination on/off.  My goal was to set illumination to a remapped key/key sequence.  So far i have the key sequence set up, i&#039;ve found what Xml file controls the on/off value, and the only thing i have left to make it work is to restart the service that controls whether or not the keyboard is lit. My plan was to make the change from on to off transparent and seamless to the user and the UAC prompt ruins that. It&#039;s a shame there isn&#039;t a way to either whitelist a process or to pass user/password info to a process without the dialog. As i&#039;ve said above i&#039;ve kind of given up and intend on using the task scheduler but that&#039;s not really it&#039;s intended purpose and was wondering if anyone had made some progress.</description> <content:encoded><![CDATA[<p>Much like stefan&#8217;s comment above, i have a situation where i need to elevate a process created in C#. Specifically i have to start/stop/restart a windows service. I can query the service just fine but actually getting the service to do something keeps on throwing an &#8220;Access is denied&#8221; exception. So far i&#8217;ve tried:</p><p>-changing the manifest file so that permission level is set to &#8220;highestAvailable&#8221; (still was deined access)<br
/> -creating my own service that would in turn restart the service i was originally targetting (this new service was then denied access to the original service &#8211; or so it seems.  furhtermore i was denied access to it.)<br
/> -trying to create my own token? (i wouldn&#8217;t consider myself completely new to c# but i&#8217;ve never really dealt with the UAC security model and i&#8217;m kind of flying blind here)</p><p>Ultimately i&#8217;ve settled on hijacking the task scheduler to run the my program in an elevated state, though this seems like an inelegant way to do things.</p><p>I get the fact that this is the very thing UAC is put in place for, namely the prevention of running potentially dangerous code without the prompting the user first.</p><p>In order to give you some background as to why i&#8217;m trying to suppress the dialog. My laptop has an illuminated keyboard but no button that directly turns it off/on. You have to drill down through a settings app and manually turn illumination on/off.  My goal was to set illumination to a remapped key/key sequence.  So far i have the key sequence set up, i&#8217;ve found what Xml file controls the on/off value, and the only thing i have left to make it work is to restart the service that controls whether or not the keyboard is lit. My plan was to make the change from on to off transparent and seamless to the user and the UAC prompt ruins that. It&#8217;s a shame there isn&#8217;t a way to either whitelist a process or to pass user/password info to a process without the dialog. As i&#8217;ve said above i&#8217;ve kind of given up and intend on using the task scheduler but that&#8217;s not really it&#8217;s intended purpose and was wondering if anyone had made some progress.</p> ]]></content:encoded> </item> <item><title>By: msp.netdev</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-2/#comment-2311</link> <dc:creator>msp.netdev</dc:creator> <pubDate>Wed, 09 Feb 2011 14:00:50 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2311</guid> <description>thanks for code, very usefull</description> <content:encoded><![CDATA[<p>thanks for code, very usefull</p> ]]></content:encoded> </item> <item><title>By: Victor</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-2/#comment-2295</link> <dc:creator>Victor</dc:creator> <pubDate>Tue, 25 Jan 2011 14:45:18 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2295</guid> <description>Stefan, can I ask you about the scenario in which you want to supress the dialog?
IMO, if UAC is active then it should stay active. Why is a problem if the credentials window is displayed?</description> <content:encoded><![CDATA[<p>Stefan, can I ask you about the scenario in which you want to supress the dialog?</p><p>IMO, if UAC is active then it should stay active. Why is a problem if the credentials window is displayed?</p> ]]></content:encoded> </item> <item><title>By: Stefan</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-2/#comment-2294</link> <dc:creator>Stefan</dc:creator> <pubDate>Tue, 25 Jan 2011 11:54:25 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2294</guid> <description>As soon as i start the second process in elevated mode, It asks for Admin credentials.
Is there a way i can supress this UI? - Maybe hardcode the admin username and password of the elevated process? (I know this is a no-no).</description> <content:encoded><![CDATA[<p>As soon as i start the second process in elevated mode, It asks for Admin credentials.<br
/> Is there a way i can supress this UI? &#8211; Maybe hardcode the admin username and password of the elevated process? (I know this is a no-no).</p> ]]></content:encoded> </item> <item><title>By: Victor</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-2/#comment-2288</link> <dc:creator>Victor</dc:creator> <pubDate>Fri, 21 Jan 2011 10:28:43 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2288</guid> <description>@Stefan,
You need a second process that will be started with elevated privileges. You cannot elevate a running process.</description> <content:encoded><![CDATA[<p>@Stefan,</p><p>You need a second process that will be started with elevated privileges. You cannot elevate a running process.</p> ]]></content:encoded> </item> <item><title>By: Stefan</title><link>http://victorhurdugaci.com/using-uac-with-c-part-1/comment-page-2/#comment-2287</link> <dc:creator>Stefan</dc:creator> <pubDate>Fri, 21 Jan 2011 09:36:51 +0000</pubDate> <guid
isPermaLink="false">http://victorhurdugaci.com/?p=638#comment-2287</guid> <description>Thanks
If i understand correctly, This should tell me whether the current user is an administrator (in the admin role) or not.
#1
How do i prompt for admin credentials if he is not?
#2
Or should i then run a second exe application (that will ask for elevation) that does the update under the &quot;\program Files\&quot; directory.
(I dont really want to split my app.)</description> <content:encoded><![CDATA[<p>Thanks</p><p>If i understand correctly, This should tell me whether the current user is an administrator (in the admin role) or not.<br
/> #1<br
/> How do i prompt for admin credentials if he is not?<br
/> #2<br
/> Or should i then run a second exe application (that will ask for elevation) that does the update under the &#8220;\program Files\&#8221; directory.<br
/> (I dont really want to split my app.)</p> ]]></content:encoded> </item> </channel> </rss>
