Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run a process as admin from a system account in Windows

Posted on 2008-11-03
3
Medium Priority
?
628 Views
Last Modified: 2013-12-04
Hello experts,

I'm running a process under the system account, and I want it to run another process as another user (of course, supplying the username and password).

I'm using the CreateProcessWithLogonW API function, which works fine when my process runs with any account, but NOT under system account... When running on system account, GetLastErr returns 5 (ACCESS_IS_DENIED).

I've tried altering the dwLogonFlags parameter, but in both flags (LOGON_WITH_PROFILE and LOGON_NETCREDENTIALS_ONLY) it behaves the same...
0
Comment
Question by:Iys
  • 2
3 Comments
 
LVL 6

Expert Comment

by:ChristianWimmer
ID: 22866668
The CreateProcessWithLogonW function does not work in a SYSTEM account. It is a "known" bug. However you can user LogonUser and CreateProcessAsUser from your service like here:

http://www.experts-exchange.com/Programming/System/Windows__Programming/Q_20687952.html?sfQueryTermInfo=1+createprocessasus

0
 

Author Comment

by:Iys
ID: 22875169
OK... not very successful:
The LogonUser func failed with the LOGON32_LOGON_BATCH logon type (as well as LOGON32_LOGON_SERVICE), and all other logon types makes the CreateProcessAsUser function fail.
The LOGON32_LOGON_NEW_CREDENTIALS logon type is the only logon type not failing the child process creation, but the child process runs under SYSTEM account again!...
0
 
LVL 6

Accepted Solution

by:
ChristianWimmer earned 2000 total points
ID: 22875253
Oh I did not see that this example uses another logon type. You should use LOGON32_LOGON_INTERACTIVE .
In a service you also need to set the token session ID using SetTokenInformation, because users may run in another session than the service (vista).

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question