#185525 - 2008-02-21 02:08 AM
Read the Event Log upon startup?
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
Is there a way to query the Application Log via a kix script and return a Yes value to a spreadsheet if Events 1030 or 1054 were found?
|
Top
|
|
|
|
#185526 - 2008-02-21 02:24 AM
Re: Read the Event Log upon startup?
[Re: endodave]
|
lukeod
Getting the hang of it
Registered: 2008-01-11
Posts: 70
Loc: Australia
|
Have a look at the UDF 'ReadEventlog' for the first bit.
There is some sample code for creating & writing to an excel document in the Samples folder bundled with the Kix v4.6 zip file - called 'excel.kix'. Might give you some pointers.
Below *should* determine if the events exist
$events_1030 = ReadEventlog('Application',1030)
$events_1054 = ReadEventlog('Application',1054)
IF $events_1030[0] <> ""
"do stuff"
ENDIF
IF $events_1054[0] <> ""
"do more stuff"
ENDIF
Luke
Edited by lukeod (2008-02-21 02:36 AM)
|
Top
|
|
|
|
#185562 - 2008-02-21 04:59 PM
Re: Read the Event Log upon startup?
[Re: lukeod]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
that is fantastic, i'll give it a try. thanks!
|
Top
|
|
|
|
#185564 - 2008-02-21 05:40 PM
Re: Read the Event Log upon startup?
[Re: lukeod]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
bummer, i don't think command exists in version 2010 (4.5). i searched through the manual and there is no mention of it. it is giving me this error:
ERROR : expected ')'! Script: \\servername\NETLOGON\admin.kix Line : 239
is there a command that will work with ver 4.5?
in fact, i don't see that command in the on-line command reference at all.
|
Top
|
|
|
|
#185567 - 2008-02-21 06:04 PM
Re: Read the Event Log upon startup?
[Re: Mart]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
cool, i had since discovered that, so i will read the how-to and hopefully that will jump start me on what i need to do to use this UDF. thanks!
|
Top
|
|
|
|
#185568 - 2008-02-21 06:07 PM
Re: Read the Event Log upon startup?
[Re: Mart]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
okay, i just read through it and as expected (since i'm not a programmer guy), i am confused by what i need to do. am i to define it as a function? i feel like i'm close to getting this to work, i just need a little more guidance. thanks!
|
Top
|
|
|
|
#185569 - 2008-02-21 06:19 PM
Re: Read the Event Log upon startup?
[Re: endodave]
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Maybe start with something like this:
; =========================================================================================== ; ; Script Information ; ; Title: ; Author: ; Description: ; ; ; =========================================================================================== ;Script Options If Not @LOGONMODE Break On Else Break Off EndIf Dim $RC $RC = SetOption("Explicit", "On") $RC = SetOption("NoMacrosInStrings", "On") $RC = SetOption("NoVarsInStrings", "On") If @SCRIPTEXE = "KIX32.EXE" $RC = SetOption("WrapAtEOL", "On") EndIf
;Declare variables
;Initialize variables
;Code
;Personal UDF Section
;UDF Section |
Now paste the UDF you found at the bottom Declare your variables under ;Declare variables Write your code under ;Code Maybe you can find your own way to structure your code afterwards
|
Top
|
|
|
|
#185570 - 2008-02-21 06:21 PM
Re: Read the Event Log upon startup?
[Re: Witto]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
sorry, don't mean to be ignorant, but now i am more confused.
|
Top
|
|
|
|
#185571 - 2008-02-21 06:23 PM
Re: Read the Event Log upon startup?
[Re: Witto]
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
; =========================================================================================== ; ; Script Information ; ; Title: ; Author: ; Description: ; ; ; =========================================================================================== ;Script Options If Not @LOGONMODE Break On Else Break Off EndIf Dim $RC $RC = SetOption("Explicit", "On") $RC = SetOption("NoMacrosInStrings", "On") $RC = SetOption("NoVarsInStrings", "On") If @SCRIPTEXE = "KIX32.EXE" $RC = SetOption("WrapAtEOL", "On") EndIf
;Declare variables DIM $events_1030, $events_1054
;Initialize variables
;Code $events_1030 = ReadEventlog('Application',1030) $events_1054 = ReadEventlog('Application',1054)
If $events_1030[0] <> "" "do stuff" EndIf
If $events_1054[0] <> "" "do more stuff" EndIf
;Personal UDF Section
;UDF Section |
Do not forget the UDF code at the bottom
|
Top
|
|
|
|
#185572 - 2008-02-21 06:26 PM
Re: Read the Event Log upon startup?
[Re: Witto]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
what do you mean by personal UDF section and UDF section? i know the green light will go off in my head here in a little bit.
|
Top
|
|
|
|
#185576 - 2008-02-21 06:45 PM
Re: Read the Event Log upon startup?
[Re: Witto]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
so when you say to include the UDF portion, you mean define ReadEventlog as a function?
|
Top
|
|
|
|
#185577 - 2008-02-21 06:52 PM
Re: Read the Event Log upon startup?
[Re: endodave]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
so, this is the UDF portion?:
function ReadEventlog() endfunction
|
Top
|
|
|
|
#185578 - 2008-02-21 07:03 PM
Re: Read the Event Log upon startup?
[Re: Witto]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
okay, so i copied and pasted the entire section of the post i found relative to the UDF. Now, when i run it, i get this error:
ERROR : array reference out of bounds! Script: \\servername\NETLOGON\admin.kix Line : 246
Line 246 is:
IF $events_1030[0] <> ""
any ideas?
|
Top
|
|
|
|
#185581 - 2008-02-21 07:15 PM
Re: Read the Event Log upon startup?
[Re: Mart]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
yes, i did that (finally!), but now i am getting the error i mentioned about the array. any ideas?
|
Top
|
|
|
|
#185584 - 2008-02-21 08:00 PM
Re: Read the Event Log upon startup?
[Re: Mart]
|
endodave
Starting to like KiXtart
Registered: 2005-08-17
Posts: 101
|
well, what's weird is i am running this against my workstation which is loaded with 1030 events.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|