B
bartlomiej.szafraniec
Hello!
How I can gain access to event log on remote machine?
Computers are in the same network but they are not in domain, they are
only in the same workgroup.
I've tried MachineName property in EventLog class but I get
exception.
I know administrator password on remote computer but how can I say
EventLog class "log in to remote computer with this username and
password"?
I code under .NET Framework 1.1
Below sample code and the exception I get
Thanks in advance for help
Bartek
// some code
try
{
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.MachineName = "lasulaptop";
log.Log = "Application";
int test = log.Entries.Count;
}
catch (UnauthorizedAccessException ex)
{
throw;
}
// some code
This is exception I get
System.UnauthorizedAccessException was caught
Message="Attempted to perform an unauthorized operation."
Source="mscorlib"
StackTrace:
at Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode,
String str)
at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive
hKey, String machineName)
at System.Diagnostics.EventLog.GetEventLogRegKey(String machine,
Boolean writable)
at System.Diagnostics.EventLog.Exists(String logName, String
machineName)
at System.Diagnostics.EventLog.OpenForRead(String
currentMachineName)
at System.Diagnostics.EventLog.get_EntryCount()
at System.Diagnostics.EventLogEntryCollection.get_Count()
at
How I can gain access to event log on remote machine?
Computers are in the same network but they are not in domain, they are
only in the same workgroup.
I've tried MachineName property in EventLog class but I get
exception.
I know administrator password on remote computer but how can I say
EventLog class "log in to remote computer with this username and
password"?
I code under .NET Framework 1.1
Below sample code and the exception I get
Thanks in advance for help
Bartek
// some code
try
{
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.MachineName = "lasulaptop";
log.Log = "Application";
int test = log.Entries.Count;
}
catch (UnauthorizedAccessException ex)
{
throw;
}
// some code
This is exception I get
System.UnauthorizedAccessException was caught
Message="Attempted to perform an unauthorized operation."
Source="mscorlib"
StackTrace:
at Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode,
String str)
at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive
hKey, String machineName)
at System.Diagnostics.EventLog.GetEventLogRegKey(String machine,
Boolean writable)
at System.Diagnostics.EventLog.Exists(String logName, String
machineName)
at System.Diagnostics.EventLog.OpenForRead(String
currentMachineName)
at System.Diagnostics.EventLog.get_EntryCount()
at System.Diagnostics.EventLogEntryCollection.get_Count()
at