Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateProcessAsUser returns error code as ERROR_INVALID_OWNER

15 views
Skip to first unread message

Dayakar

unread,
Mar 31, 2010, 6:13:01 AM3/31/10
to

I tried to start a process(Eg: notify.bat) as a user from within a service
which runs under localsystem.

Now the Problem is, I get the Error 1307 ERROR_INVALID_OWNER when calling
LogonUser and CreateProcessAsUser.
The strange thing is, the method returns true, saying it succeeded.

The process(Notify.bat) starts when userid and password passed on to
LogonUser API has admin previlages. But the process(Notify.bat) doesn't get
invoked when the credentials passed on to LogonUser has no admin previlages.

Therefore, it seems like the token having non admin previlages does not
allow to invoke process using CreateProcessAsUser API.

BUT, in both the cases(admin and nonadmin user) the method
CreateProcessAsUser returns true but the error code returns
ERROR_INVALID_OWNER.

Can you please let me know the following queries?
1. Does CreateProcessAsUser invokes the process if the token passed doesn't
have admin previlages?
2. Why does CreateProcessAsUser returns error code (ERROR_INVALID_OWNER)
even when function returns successful?

Here is the code snippet


if(!LogonUser(remoteuser, remotedomain, remotepassword,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, &token))
{
dwErr = GetLastError();
}


// obtain a handle to the interactive windowstation
//
hwinsta = OpenWindowStation(
"winsta0",
FALSE,
READ_CONTROL | WRITE_DAC
);
if ( hwinsta == NULL )
return -1;


hwinstaold = GetProcessWindowStation();

//
// set the windowstation to winsta0 so that you obtain the
// correct default desktop
//

if ( !SetProcessWindowStation( hwinsta ) )
return -1;

//
// obtain a handle to the "default" desktop
//
hdesk = OpenDesktop(
"default",
0,
FALSE,
READ_CONTROL | WRITE_DAC | DESKTOP_ALL
/*DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS */
);

if ( hdesk == NULL )
{
SetProcessWindowStation( hwinstaold ); //set it back
return -1;
}

memset(&StartupInfo, 0, sizeof(StartupInfo));
StartupInfo.cb=sizeof(StartupInfo);
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_MINIMIZE;
StartupInfo.lpDesktop = "winsta0\\default";

ProcessInfo.hProcess = NULL;
ProcessInfo.hThread = NULL;

rc = CreateProcessAsUser(token,
NULL,
cmdline,
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
NULL,
NULL,
&StartupInfo,
&ProcessInfo);

The program(Notify.bat) gets executed successfully but still I get an error
code of CreateProcessAsUser shows as "ERROR_INVALID_OWNER".

NOTE: I don't receive the above error if I user having admin previlages
invoke the same code snippet from seperate application(.exe). I mean instead
of calling/invoking process(batch file) from service, try from another
process(.exe) which resulted with no error.


Wilson, Phil

unread,
Mar 31, 2010, 12:53:53 PM3/31/10
to
What OS are you running this on? Is it a UAC/services in isolated session
OS?

--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


"Dayakar" <Day...@discussions.microsoft.com> wrote in message
news:FEE32C1E-D884-4CFB...@microsoft.com...

Dayakar

unread,
Apr 1, 2010, 2:16:01 AM4/1/10
to
Hi Phil,

Thanks for your response.

My application is running under Windows XP SP2.

Regards,
Dayakar

0 new messages