Click here to Skip to main content
14,696,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have two accounts on my system.
One is admin and another is guest.
When system starts it automatically boots in guest login.
I want to start one process which requires admin privileges.
How will i start that process under admin user in guest login without log off?
I used run as command but it requires user interface for entering the password for admin user.
I want the solution which does not require any user interface to staring the process.
Is there any win32 api which is useful for the same??

Thanks in advance.

RJ :)

If it requires admin access, the UAC will take care of it by prompting you for an admin password. Of course, I'm assuming that you're using Win7 or Vista.
Sandeep Mewara 10-Feb-11 8:00am
Comment from OP:
I am using win XP.
But i don't want any user interface which will enter the password.
I want solution which works fine without any use4r interface means either it will read the user credential from file or from some static place.
Even i just want win32 api's which will do the same stuff for me.
Similar to CreateProcess
Sergey Alexandrovich Kryukov 10-Feb-11 11:10am
Do you want magic?
Sandeep Mewara 10-Feb-11 11:55am
Sergey Alexandrovich Kryukov 10-Feb-11 11:11am
That's correct, a 5,
You should "impersonate" the admin. And the security subsystem will in any case ask for an authentication.
What you're doing is -in fact- introducing a security leak (and make your software to be considered "malware": it is presented as a user app, but it tries to interact with the user's system without the user have any knowledge about that).

What do you think if I write an app that uses your credit card without even asking you anything?
Member 7359839 14-Feb-11 3:51am
I don't know what are you talking about.
This is required functionality because it is not possible for admin all the time to login on system in that case he will provide some functionality by which he can log in on system without logging off current user.
And that what I required in which admin gave permission to execute the commands.
I hope now you understand my problem statement.
Emilio Garavaglia 14-Feb-11 4:24am
Please understand that what you're asking introduces a security leak: if you are executing something in the "user" space, the "user" cannot self-promote into an "admin" without a proper authentication. Otherwise whatever malware the user may download will have very simple life in making the system like it wants, without any sort of permission.

To do that kind of actions, you need a **service** that runs into the machine under "admin" priviledge, before the user logs in. You should then start your activity by an action of that process.
Member 7359839 14-Feb-11 4:31am
I want to get admin privileges only for executing my commands like registering ocx control etc etc.
I will not give same privileges to all application in normal user log in.
So understand the problem statement.
I don't have any monitor on my device so i want some application or command which will run in normal user login with admin privileges.
After completing its task the normal user privileges are remains available for all other processes.
Try this link:[^]

I think you want CreateProcessAsUser() or CreateProcessWithLogonW().
Member 7359839 14-Feb-11 3:54am
I used CreateProcessAsUser in my application but this api doesn't provides the required privileges.
After executing command it gives the error "Access Denied".
I think it will work with CreateProcessWithLogonW but I'm getting some problem in including header files required for this api.

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