Link to home
Start Free TrialLog in
Avatar of Iys
Iys

asked on

Run a process as admin from a system account in Windows

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...
Avatar of ChristianWimmer
ChristianWimmer
Flag of Albania image

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:

https://www.experts-exchange.com/questions/20687952/Service-and-CreateProcessAsUser.html?sfQueryTermInfo=1+createprocessasus

Avatar of Iys
Iys

ASKER

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!...
ASKER CERTIFIED SOLUTION
Avatar of ChristianWimmer
ChristianWimmer
Flag of Albania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial