Write to eventlog from batch file

View: New views
6 Messages — Rating Filter:   Alert me  

Write to eventlog from batch file

by Bugzilla from spam@network-technologies.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would like to write Error messages to eventlog if something does not
work as expected with my backup batch file.

How can I do this? Is there a windows command which allows me to add
entries to eventlog from the command line?

Thanks
John

Re: Write to eventlog from batch file

by Michael Burek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can append to a file by using double greater than signs: >>

rem This will overwrite the file each time:
echo Overwrite this line > log.txt
echo Starting Test > log.txt

rem This will append to the end of the file:
echo Passed Test 1 >> log.txt
echo Failed Test 2 >> log.txt
type log.txt
rem Starting Test
rem Passed Test 1
rem Failed Test 2

On Tue, Feb 17, 2009 at 9:12 AM, John Black
<spam@...> wrote:

>
> I would like to write Error messages to eventlog if something does not
> work as expected with my backup batch file.
>
> How can I do this? Is there a windows command which allows me to add
> entries to eventlog from the command line?
>
> Thanks
> John
>

Re: Write to eventlog from batch file

by Bugzilla from spam@network-technologies.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Burek wrote:
> You can append to a file by using double greater than signs: >>

Yes but what about the MS Windows event log? The one Event Viewer displays?

Thanks

Re: Write to eventlog from batch file

by Michael Burek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oops, sorry about that.  Do you have any opposition to calling a
Windows/VB script file?

http://www.mcotis.com/scripting/windows_event_log_batch_file

Google: write to windows event log dos

Gotta head to work, so can't try these out myself right now.


On Tue, Feb 17, 2009 at 9:40 AM, John Black
<spam@...> wrote:
> Michael Burek wrote:
>> You can append to a file by using double greater than signs: >>
>
> Yes but what about the MS Windows event log? The one Event Viewer displays?
>
> Thanks

Re: Write to eventlog from batch file

by Michael Burek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh, it looks like there might be a command line utility for this in
the Windows Resource Kit:
http://www.ss64.com/nt/logevent.html


On Tue, Feb 17, 2009 at 9:54 AM, Michael Burek <mike@...> wrote:

> Oops, sorry about that.  Do you have any opposition to calling a
> Windows/VB script file?
>
> http://www.mcotis.com/scripting/windows_event_log_batch_file
>
> Google: write to windows event log dos
>
> Gotta head to work, so can't try these out myself right now.
>
>
> On Tue, Feb 17, 2009 at 9:40 AM, John Black
> <spam@...> wrote:
>> Michael Burek wrote:
>>> You can append to a file by using double greater than signs: >>
>>
>> Yes but what about the MS Windows event log? The one Event Viewer displays?
>>
>> Thanks
>

Re: Write to eventlog from batch file

by Bugzilla from spam@network-technologies.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Burek wrote:
> Oh, it looks like there might be a command line utility for this in
> the Windows Resource Kit:
> http://www.ss64.com/nt/logevent.html

I found that site before but I did not see the command on the MS
Resource Kit 2003 website.

Thanks for the VB script link, I will look into it.

Thanks
John