Page 1 of 2 12>
Topic Options
#185525 - 2008-02-21 02:08 AM Read the Event Log upon startup?
endodave Offline
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 Offline
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

 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


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 Offline
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 Offline
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
#185565 - 2008-02-21 05:50 PM Re: Read the Event Log upon startup? [Re: endodave]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
It is not a build in function or command. It is a UDF created by one of the members to add functionality to kixtart that is not (yet) included.

UDF Library » ReadEventlog() - Retrieves event from the eventlog
KiXtart FAQ & How to's » How to use UDFs
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#185567 - 2008-02-21 06:04 PM Re: Read the Event Log upon startup? [Re: Mart]
endodave Offline
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 Offline
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 Offline
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 Offline
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 Offline
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 Offline
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
#185573 - 2008-02-21 06:27 PM Re: Read the Event Log upon startup? [Re: endodave]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Just a distinction I make between UDF I borrowed from the Internet and my personal ones
Top
#185576 - 2008-02-21 06:45 PM Re: Read the Event Log upon startup? [Re: Witto]
endodave Offline
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 Offline
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 Offline
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
#185580 - 2008-02-21 07:14 PM Re: Read the Event Log upon startup? [Re: endodave]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
All you need to do is paste the ReadEventLog code to the bottom of the script.
Kix will read the code into memory and after that you can use the ReadEventLog function just like you would use the Exist or Writeline or any other build in function. You can just call upon it every time you need it.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#185581 - 2008-02-21 07:15 PM Re: Read the Event Log upon startup? [Re: Mart]
endodave Offline
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
#185583 - 2008-02-21 07:55 PM Re: Read the Event Log upon startup? [Re: endodave]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Ok sorry I should read better.

If there are no 1030 events the array will be empty so you might want to add a check to see If it is empty before using one or more of the elements in the array.

 Code:
If Ubound($events_1030) <> "-1"
	;do you stuff
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#185584 - 2008-02-21 08:00 PM Re: Read the Event Log upon startup? [Re: Mart]
endodave Offline
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
#185585 - 2008-02-21 08:12 PM Re: Read the Event Log upon startup? [Re: endodave]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Weird indeed. Can you post the code you are using? I'll run it on my machine to see what goes wrong.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.075 seconds in which 0.024 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org