Vista: OpenService() returns Access Denied

M

Mark Findlay

Our win32 app opens the Task Scheduler to enumerate tasks as follows:

SC_HANDLE hSC = NULL;
SC_HANDLE hSchSvc = NULL;

hSC = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (hSC == NULL) return GetLastError();
hSchSvc = OpenService(hSC, "Schedule", SERVICE_START |
SERVICE_QUERY_STATUS);

This works fine on current Windows platforms, but on Microsoft Vista the
OpenService fails and GetLastError() returns 5 ("Access Denied").

We get this even when the app is running under Admin context, and have also
tried setting the app's security privilege to SE_DEBUG_NAME.

Is this just a Vista BETA issue at this point, or is there a new security
mechanism in place that we need to program for (and if so, what changes do
we need to make)?

Thanks!
 
M

Mark Findlay

Thanks Jane,

I've been through a good chunk of the site you referenced and it appears
that we're not in Kansas anymore :) It looks like I need to create an
Application Manifest and rebuild the app with this in order to enable the
admin privileges necessary to execute the OpenService() call. Also, it
appears that I need to rebuild with Visual Studio 7 (I am currently using
Visual Studio 6) in order to include the Application Manifest. Finally, I
will also need to digitally sign the application.

I am going to proceed along these lines. Meanwhile, am I on the right track
with this? Any other advice you would offer to a Vista novice at this point?

Thanks!
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top