forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Need help with Eventlog writing using CodeScript code

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Thu Jan 26, 2006 6:38 pm    Post subject: Need help with Eventlog writing using CodeScript code Reply with quote

Hi,

I found this old code that codescript wrote a while back, which basically writes information an eventlog and the NT eventviewer.

I can't seem to make it work properly... It does write to the event viewer, but the Hello word is all garbaged.

Anyone know why?

Here is the code:

Code:
rem Please Note that the script will work only after
  REM you install the vds update giving you the ability
  REM to use more than 8 parameters in @LIB() function.
  REM Else the app will simply crash !
  REM You use this script entirely at your own risk.
  IF @SYSINFO(ISNT)
   goto START
  ELSE
    %R = @msgbox(NT Event Log cannot be written on a non NT OS !!!,Wrong Operating System,$010)
  EXIT
   
:START 
  TITLE Writing NT Event Log CodeSript
  DIALOG CREATE,Writing NT Event Log CodeSript,-1,0,377,135
  DIALOG ADD,BUTTON,BUTTON1,51,78,216,41,Write Hello World to C:\testlog.evt
  DIALOG SHOW


:EVLOOP
WAIT EVENT
GOTO @EVENT()

:BUTTON1BUTTON
REM %1 = Eventlog file to open.
%1 = "C:\testlog.evt"
REM +++++++++++++++++
REM %2 = event type
REM EVENTLOG_SUCCESS = $0
REM EVENTLOG_ERROR_TYPE = $1
REM EVENTLOG_WARNING_TYPE = $2
REM EVENTLOG_INFORMATION_TYPE = $4
REM EVENTLOG_AUDIT_SUCCESS = $8
REM EVENTLOG_AUDIT_FAILURE = $10
REM EVENTLOG_SEQUENTIAL_READ = $1
REM EVENTLOG_SEEK_READ = $2
REM EVENTLOG_FORWARDS_READ = $4
REM EVENTLOG_BACKWARDS_READ = $8
%2 = $1

REM ++++++++++++++
REM %3 = event category
REM Specifies the event category.
REM This is source-specific information;
REM the category can have any value.
%3 = 1

REM +++++++++++++++
REM %4 = Specifies the event.
REM The event identifier specifies the message that
REM goes with this event as an entry in the message
REM file associated with the event source.
%4 = 1

REM +++++++++++++++
REM %5 = Pointer to the current user's security identifier.
REM This parameter can be NULL if the security
REM identifier is not required.
%5 = 0

REM +++++++++++++++
REM %6 = Specifies the number of strings in the array
REM pointed to by the lpStrings parameter.
REM A value of zero indicates that no strings are present.
%6 = 1

REM +++++++++++++++
REM %7 = Specifies the number of bytes of event-specific
REM raw (binary) data to write to the log. If this parameter
REM is zero, no event-specific data is present.
%7 = 0

REM +++++++++++++++
REM %8 = Pointer to a buffer containing an array
REM of null-terminated strings that are merged into the
REM message from the message file before Event Viewer displays
REM the string to the user. This parameter must be a valid pointer
REM (or NULL), even if wNumStrings is zero.
REM Each string has a limit of 32K bytes.
%8 = "Hello world"

REM +++++++++++++++
REM %9 = Pointer to the buffer containing the binary data.
REM This parameter must be a valid pointer (or NULL),
REM even if the dwDataSize parameter is zero.
%9 = 0

REM *******************************************
REM The parameters are given local variables 1-9
REM so that you can easily divide the part below
REM as a seperate include file or a DSU after defining
REM a custom function/command for the same.
REM *******************************************

LOADLIB advapi32.dll
LOADLIB kernel32.dll
%H = @LIB(advapi32,OpenEventLogA,INT:,NIL:,STR:%1)
REM This commmand below will clear all the entries present
REM It is only OK for custom event log like this
REM If You are using on default log file REM it,
REM Else all the logs are cleared.
#%C = @LIB(advapi32,ClearEventLogA,INT:,INT:%H,NIL:)
%M = %8
%B = @LIB(advapi32,ReportEventA,BOOL:,%H,%2,%3,%4,%5,%6,%7,@ADDR("%M"),%9)
%R = @BINARY(DWORD,0)
%O = @BINARY(DWORD,0)
%B = @LIB(advapi32,GetNumberOfEventLogRecords,BOOL:,INT:%H,@ADDR("%R"))
%B = @LIB(advapi32,GetOldestEventLogRecord,BOOL:,INT:%H,@ADDR("%O"))
%F = %1
%B = @LIB(advapi32,BackupEventLogA,BOOL:,INT:%H,@ADDR("%F"))
%B = @LIB(advapi32,CloseEventLog,BOOL:,INT:%H)
FREELIB advapi32.dll

REM End of API functions

#INFO There are @VAL(%R) records now in your event log file %1 !@CR() Oldest record number is @VAL(%O)

#INFO Now open your eventlog %1 from event viewer Options Menu which will be launched shortly.
SHELL OPEN,eventvwr
GOTO EVLOOP

:CLOSE
EXIT



Thanks
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Jan 26, 2006 7:35 pm    Post subject: Reply with quote

Never used this, but have you tried: %8 = "Hello world"$chr(0)
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Thu Jan 26, 2006 7:59 pm    Post subject: Reply with quote

Thanks sheep..but still no luck I get "The eventlog is corrupted now" Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group