Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I am developing a Windows Application in C#...
Sometimes I need administrative privilege to carry out some tasks in the program...
and, I dont want the application to ask for Administrative privileges at the startup,
I only need the program to ask when the task comes,,,,
How can I make it in my prgram ?
Posted

1 solution

You cannot.
Basically, all applications which pretend to do so use some hacks.
E.g. TaskManager: when you want to see tasks of all users, the program shuts down and restarts with admin priviledges.
Another possibility is to launch a different exe for the administrative tasks, and that exe is started with admin priviledges. in this case, your original program continues to run with normal user priviledges.
Now you may choose one of the two hacks or ask the user to start your program as admin when he plans to do such tasks.
 
Share this answer
 
v2
Comments
Sushil Mate 14-Aug-13 5:51am    
I have seen same question before, hope this Link[^] help him to understand better.
Yesudasan Moses 14-Aug-13 6:39am    
Thanks dear friend.... I was suspecting that this maybe the solution... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900