From: almurph on
Hi,


I'm very new to VBScript but can write C# and VB.NET. I want to
write .vbs file that calls the following code below (all it does is
insert an event folder into the event log)
Problem is though I don't know how to do this exactly. Can anyone
provide some code sampels as how to call this or incorportate it into
a .vbs? Would agreatly appreciate any examples/code-samples/
suggestions etc....

Much thanks,
Al.

**** VB.NET Example ***


Public Sub Main()

Dim eventLogName As String = "LogTest14"

WriteToReg(eventLogName)

End Sub



Private Sub WriteToReg(ByVal eventLogName As string)

Try

If Not (System.Diagnostics.EventLog.SourceExists(eventLogName)) Then
System.Diagnostics.EventLog.SourceExists(eventLogName,
eventLogName)
End If

Catch e As Exception
Console.WriteLine("Reg Write Exception: " +
e.Detail.Item("ErrorCode").InnerText + " (" +

e.Detail.Item("Message").InnerText + ")")




End Sub
From: Mayayana on
The help file for VBS and WSH is here:

http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9

It looks like LogEvent is the method you want.

You need to do some research and not expect
to just dump .Net code and get a translation.
Only .Net programmers will be familiar with the
gigantic, spoon-fed object model of .Net.

I've never heard of event logging before, but I
had no trouble finding out via Google. Google is
also how I found the VBScript LogEvent method.
You could have done the same.


| I'm very new to VBScript but can write C# and VB.NET. I want to
| write .vbs file that calls the following code below (all it does is
| insert an event folder into the event log)
| Problem is though I don't know how to do this exactly. Can anyone
| provide some code sampels as how to call this or incorportate it into
| a .vbs? Would agreatly appreciate any examples/code-samples/
| suggestions etc....
|
| Much thanks,
| Al.
|
| **** VB.NET Example ***
|
|
| Public Sub Main()
|
| Dim eventLogName As String = "LogTest14"
|
| WriteToReg(eventLogName)
|
| End Sub
|
|
|
| Private Sub WriteToReg(ByVal eventLogName As string)
|
| Try
|
| If Not (System.Diagnostics.EventLog.SourceExists(eventLogName)) Then
| System.Diagnostics.EventLog.SourceExists(eventLogName,
| eventLogName)
| End If
|
| Catch e As Exception
| Console.WriteLine("Reg Write Exception: " +
| e.Detail.Item("ErrorCode").InnerText + " (" +
|
| e.Detail.Item("Message").InnerText + ")")
|
|
|
|
| End Sub


From: Kenneth A. Larsen on

<almurph(a)altavista.com> wrote in message
news:2e4a9820-afb6-47df-8b2b-e59390e347d6(a)b34g2000yqm.googlegroups.com...
> Hi,
>
>
> I'm very new to VBScript but can write C# and VB.NET. I want to
> write .vbs file that calls the following code below (all it does is
> insert an event folder into the event log)
> Problem is though I don't know how to do this exactly. Can anyone
> provide some code sampels as how to call this or incorportate it into
> a .vbs? Would agreatly appreciate any examples/code-samples/
> suggestions etc....
>
> Much thanks,
> Al.
>
> **** VB.NET Example ***
>
>
> Public Sub Main()
>
> Dim eventLogName As String = "LogTest14"
>
> WriteToReg(eventLogName)
>
> End Sub
>
>
>
> Private Sub WriteToReg(ByVal eventLogName As string)
>
> Try
>
> If Not (System.Diagnostics.EventLog.SourceExists(eventLogName)) Then
> System.Diagnostics.EventLog.SourceExists(eventLogName,
> eventLogName)
> End If
>
> Catch e As Exception
> Console.WriteLine("Reg Write Exception: " +
> e.Detail.Item("ErrorCode").InnerText + " (" +
>
> e.Detail.Item("Message").InnerText + ")")
>
>
>
>
> End Sub

You are very welcome!


From: "Dave "Crash" Dummy" on
Mayayana wrote:
> The help file for VBS and WSH is here:
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9
>
>
> It looks like LogEvent is the method you want.
>
> You need to do some research and not expect to just dump .Net code
> and get a translation. Only .Net programmers will be familiar with
> the gigantic, spoon-fed object model of .Net.
>
> I've never heard of event logging before, but I had no trouble
> finding out via Google. Google is also how I found the VBScript
> LogEvent method. You could have done the same.

Here is another good place to look
http://msdn.microsoft.com/en-us/library/ms950396.aspx

BTW, when I am looking for MS related stuff, I use the Bing engine. I
don't know if it makes any difference, but since Bing is a MS thing...
--
Crash

"When you get to a fork in the road, take it."
~ Yogi Berra ~
 | 
Pages: 1
Prev: Loop folder
Next: Right Click FTP