Windows 7 - OpenService for starting a service - access denied

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

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

http://msdn.microsoft.com/en-us/library/ms685981(VS.85).aspx#access_rights_for_a_service

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
SERVICE_ALL_ACCESS or SERVICE_START.

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.

Thanks
Novan




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
GV
Novan replied on 14-Aug-09 12:31 PM
Thanks,

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