Starting administrator progs from a service using Windows VISTA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a problem in launching an application through my service. I am
trying to launch e. g. update.exe through my service. The update.exe has a
UI. The UI should displayed on the current desktop. But the update.exe has to
run
with admin rights. Therefore a UserAccount exits.

I´m trying this stuff with using the "CreateProcessAsUser" API function.

Here my code (pieces):
if (LogonUser(szUserName, _T("."), szPwd, LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, &hUser) == FALSE)
{ //error
}
else
{
if (CreateProcessAsUser(hUser, NULL, szComLine, NULL, NULL, FALSE,
CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi) == 0)
{ //error

}
}

CreateProcessAsUser failed. GetLastError is 740. And the error msgbox is
displayed in session0 (Service session on VISTA!).

What make I wrong?

Maybe there is another possibility to start my update.exe. Without using a
admin account. Perhaps I can impersonate the current launching process
(update.exe) from User Rights to admin rights. Is there a possibility?

Many thanks for your answer.
 
Hello,

I found this bit of information in the MSDN forums that may help you:

1. use the LogonUser API to logon on the admin user and get their (not
elevated) “filtered†token. You can also get the user token of an existing
process running as admin.

2. call GetTokenInformation with the InformationClass set to
TOKEN_LINKED_TOKEN to get the full (elevated) token.

3. You can then impersonate to the higher privileged token and spawn from
there
 
Back
Top