Windows 7 - OpenService for starting a service - access denied

Asked By Novan on 14-Aug-09 07:06 AM

I am logged in with a normal Administrator account of Win7 RC but when I want
to execute the following C++ statement I get a Access denied error (5)

serviceHandle = OpenService(serviceControlManagerHandle,
ddsDriverUMComponents.ddsGetDriverName(), SERVICE_START);

Does the normal Administrator account (the default account after the Win7 RC
installation) not have the SERVICE_START access right? If I look up my user
account in the control center there is written "Administrator" and if I look
on the following web page

Administrators (on the bottom of the page) does have the SERVICE_ALL_ACCESS
which include SERVICE_START but my Administrator account seem not  to have

While developing my Service (its a driver for WFP) I used the build in
Administrator account (which must explicitly activated) and there the start
works fine. But the end users have not this account. They have maximum a
normal Administrator account.


Gianluca Varenni replied on 14-Aug-09 10:29 AM
Do you have UAC enabled? If it is a fresh Win7 installation, probably yes.

Does your test application run with elevated privileges?

Have a nice day
Novan replied on 14-Aug-09 12:31 PM

with a manifest option that the exe should run with administrator rights the
application run as wanted.