-1

Possible Duplicate:
Request UAC Elevation c#

In my application, I need to save a file to the programs directory, which requires the administrator privileges. How can I prompt the user to ask for such permission, for example with the usual windows' dialogbox?

Community
  • 1
  • 1
Cippo
  • 1,001
  • 4
  • 14
  • 26

2 Answers2

0

In case you don't know how to set these rights, you might want to check out this post:

Set administrative rights C#

Community
  • 1
  • 1
voluminat0
  • 866
  • 2
  • 11
  • 21
-2

If I understand your question correctly, it's how to ask for the permission, so I assume you already understand how to set it. This is a way you could ask for yes / no.

DialogResult result = MessageBox.Show("The question", "Title", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
    //set the admin rights
} 
else if (result == DialogResult.No)
{
    //do something else
}
CuccoChaser
  • 1,059
  • 2
  • 15
  • 27
  • This works if I want the user to agree to something normal but my problem is that I need the user to agree to give my application the permission to write a program in a privilegied path. – Cippo Jan 09 '13 at 20:08
  • Does not answer – miguelmpn Jun 29 '20 at 18:40