You can use impersonation but that requires storing the
username/password of an admin which you probably don't want to do.
A better option is to use a windows service which can be set to run as
an admin user. It can do whatever automatic stuff is needed and then
exit.
If you need it to be tied to someone logging in instead of just when
the computer starts up you can still use a windows service for the
real work, set it to manual start, and then have a winform app that
runs on startup and uses ServiceController to start up the windows
service (which can shut itself down when done).
HTH,
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On 13 Dec 2006 13:17:47 -0800, "TravisTurman"
<tr***********@corphealth.comwrote:
>I'm a C# newbie and have inherited a program that runs at login. Part
of the program looks at a text file to see which version is installed
and then installs the latest greatest version if needed. In order for
this to work, the person logging into the Windows XP desktop needs to
have local admin rights on the machine. Is there a way using C# to
give the current user the necessary rights, or put them in the local
administrators group, when this application starts and then put them
back to the way they were when the program finishes running?
Any help would be greatly appreciated.