473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Temporarily give the current user Local Admin rights

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.

Dec 14 '06 #1
5 5512
Consider what you're asking for and then consider why the OS may try
and prevent this.

Now if your program is running UNDER an administrative account to set
something up later, that's a different story, but that doesn't appear
to be what you're asking for.

On Dec 13, 4:17 pm, "TravisTurman" <travis_tur...@corphealth.com>
wrote:
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.
Dec 14 '06 #2

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.
Dec 14 '06 #3
I'm not sure I understand you. Let me see if I can clarify what I'm
talking about. Right now I am a local administrator over my
workstation, but if I log in on another workstation I'm not a local
administrator unless someone with administrator access adds me to the
local administrator group on the workstation. What I'd like to have
happen is no matter which workstation I log into, I want to be a local
administrator while our PC inventory program runs and then be removed
from the local admin group when it's done.

Does this make sense?

Michael Letterle wrote:
Consider what you're asking for and then consider why the OS may try
and prevent this.

Now if your program is running UNDER an administrative account to set
something up later, that's a different story, but that doesn't appear
to be what you're asking for.

On Dec 13, 4:17 pm, "TravisTurman" <travis_tur...@corphealth.com>
wrote:
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.
Dec 14 '06 #4
Thanks for the info, Sam, but being a C# newbie I'm not sure how to
code something like this. The last option you mention sounds like what
I'm looking for. Do you have some sample code I can look at or know
where I can find some?

Samuel R. Neff wrote:
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.
Dec 14 '06 #5
"TravisTurman" <tr***********@corphealth.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
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.

Just schedule the program to run at each user logon using Wndows task scheduler.

Willy.

Dec 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marc Walgren | last post by:
Greetings I have an ASP application to enter reservations. There are multiple user security settings that require some users to have a restricted list of client in a drop list on a form. I...
3
by: jean-dot-paul-at-opelwilly-dot-com | last post by:
Hello all, I have two different applications where my application wants to do something the logged user has not the rights to: 1) Change a HKEY_LOCAL_MACHINE key value. The user has only...
2
by: klh | last post by:
Our network staff has decided to implement a new user id structure of the form "fred.smith". We're running DB2 PE 7.1 FP7 on Windows XP. Now any commands issued in a command window receive an...
6
by: Tim Werth | last post by:
I posted this to microsoft.public.dotnet.general then I saw posts about services on this newsgroup. So, sorry for the independent cross-posting. This might not be the best place to post this,...
6
by: Andrew Chalk | last post by:
My application attempts to connect to an SQL Server database as name ASPNET and Login Name SERVERNAME/ASPNET in response to these commands: SqlConnection myConnection = new SqlConnection("Data...
1
by: Bill Nguyen | last post by:
I tried to rename a local folder (C:\Program Files\Microsoft Mappoint\Data) in my VB.NEt app but running into permission problem. I even granted full rights to ASPNET user to the folder in...
3
by: jojobar | last post by:
Hello, I am trying to localize an existing application (asp.net 2.0). using implicit as well as explicit localization. Asp.net 2.0 uses App_LocalResources folder for implicit localization....
3
by: Charlotte | last post by:
Hello, info: I'me a rookie with IIS I have on a WinXP Pro the IIS installed, so I can test some pages before uploading to the hostserver online on the hostserver is a possibility (with the...
2
by: Scott | last post by:
Attempting to install WCF service on stand alone 2003 server as a admin user (not administrator but user "WCF" i.e user added to local admin group). It fails with user error: The description...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.