Hi Experts,
I have tried to use the code you posted in a website to perform the Event
Log backup using vb.net.
However,when I run the code, the program prompt an error saying that
"Invalid Parameter". The program stops at
Dim outParams As ManagementBaseObject =
classInstance.InvokeMethod("BackupEventLog", inParams, Nothing).
Below is the details error message:
System.Management.ManagementException was caught
Message="Invalid parameter "
Source="System.Management"
StackTrace:
at
System.Management.ManagementException.ThrowWithExt endedInfo(ManagementStatus
errorCode)
at System.Management.ManagementObject.InvokeMethod(St ring methodName,
ManagementBaseObject inParameters, InvokeMethodOptions options)
at EventLogAutomation.Module1.BackupEventLog() in C:\Documents and
Settings\seokbee.TEKKLSVR\My Documents\Visual Studio
2005\Projects\EventLogAutomation\EventLogAutomatio n\EventLog.vb:line 167
Basically my code is as follow:
Try
Dim classInstance As New ManagementObject( _
"root\CIMV2", _
"Win32_NTEventlogFile.Name='C:\WINDOWS\system32\co nfig\AppEvent.Evt'",
Nothing)
Dim inParams As ManagementBaseObject =
classInstance.GetMethodParameters("Copy")
inParams("FileName") = "c:\sample.txt"
Dim outParams As ManagementBaseObject = _
classInstance.InvokeMethod("Copy", inParams, Nothing)
Console.WriteLine("Out parameters:")
Console.WriteLine("ReturnValue: {0}", outParams("ReturnValue"))
Catch err As ManagementException
End Try
Anyone has any idea on this issue?
Many thanks in advance.
Regards,
Seok Bee