Suppress DCOM error when attempting to Read Remote Registry from vb.net

T

Tim Frawley

I am have created a reporting tool for our network to output various
information we are interested in like Microsoft Office versioning
information and etc. One of the things I have to do is attempt to Read
the machines Registry remotely like so:

Private Function ReadRegistryKey(ByVal strRLoc As String, _
ByVal strSubKey As String, ByVal strVal As String, _
ByVal strMachineName As String) As String
Dim rKey As RegistryKey, sKey As String
Try
rKey =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,
strMachineName)
rKey = rKey.OpenSubKey(strRLoc & strSubKey)
sKey = rKey.GetValue(strVal)
Return sKey
Catch ex As Exception
Return ""
End Try
End Function

If the Remote Registry service has been disabled or the computer is off
then I am getting a System event log entry:

Event Type: Error
Event Source: DCOM
Event Category: None
Event ID: 10009
Date: 2/4/2005
Time: 1:52:01 PM
User: XXX\xxxxxxxx
Computer: XXXXXXXXXX
Description:
DCOM was unable to communicate with the computer XXXXXXX using any of
the configured protocols.

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.


I would like to supress these event log entries if possible.

Does anyone have any ideas on what I would need to do?

Sincerely,

Timothy Frawley
 
N

Nikolay Petrov

best guess this is part of the DCOM functionality, which logs error.
i am quite sure that you will be unable to supress these log entries.

so you can do 2 things, first cheif if the machine is online, and then
check if the Remote Registry service is running.
 
P

Peter Huang [MSFT]

Hi Tim,

I agree with Nikolay's suggestion. Also .NET provide a ServiceController,
which will help us to determine the service on remote machine. We use
try..catch, in case the remote machine is down.

Imports System.ServiceProcess
Module Module1
Sub Main()
Try
Dim sc As New ServiceController
sc.MachineName = "remotemachinename"
sc.ServiceName = "RemoteRegistry"
Console.Write(sc.Status.ToString())
Catch ex As Exception
Console.Write(ex.ToString())
End Try
End Sub
End Module

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Tim Frawley

Thank you both, Nikolay and Peter,

Your posts where very helpful. I have applied your suggestions and I
believe I will no longer have DCOM errors in the event log!!

Thank you again!

Tim
 
P

Peter Huang [MSFT]

Hi Tim,

I am glad that our suggestion helped you, and thank Nikolay for sharing the
knowledge in the community. :)

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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