Pergunta

I'm using VB6 and using ADSI to query for the status (running or not) of a Windows Service. See this MS article: http://msdn.microsoft.com/en-us/library/aa746322(v=vs.85).aspx.

With a user who is a member of the USERS group, I'm receiving a thrown exception. I believe it's on the GetObject method:

Set comp = GetObject("WinNT://.,Computer")

The exception is: 80070005 "General access denied error"

Running the same code as a member of POWER USERS, however, works just fine.

Elevating all users to Power users isn't an option. What exact rights do I need to have granted in order for this function to run successfully?

I've tried running procmon.exe, and wasn't able to determine from the output as to what or where a denial is occurring.

Thanks!

Edit: This is running on XP sp2.

Foi útil?

Solução

Sounds like you're running into a UAC barrier. I'm not familiar with IADsService, but it is hardly necessary in determining if a Windows service is running. Have you considered using API functions to query your service? Try QueryServiceStatus on a service opened with SERVICE_QUERY_STATUS.

Outras dicas

There is no need for heavyweight administrative services or API calls. The Shell Automation interface has offered this for some time (Win2K or later, Shell32.dll v. 5.0 or later):

With CreateObject("Shell.Application")
    MsgBox .IsServiceRunning("MSMQ")
End With

Works fine for me without elevation.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top