Backing Up and Clearing Event Logs If the Log Meets Specific Conditions

J

james

I am new to scripting using WScript/Cscript. When I run
the script to Backing Up and Clearing Event Logs If the
Log Meets Specific Conditions i get the following error:
->terminated entity reference - matching ';' not found

I have successfully loaded Windows Script V5.6 on a
Windows NT 4.0 Build 1381. I need this script to run
successfully on Windows 2000.

Script below:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup,
Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("SELECT * FROM Win32_NTEventLogFile")
For Each objLogfile in colLogFiles
If objLogFile.FileSize > 20000000 Then
strBackupLog = objLogFile.BackupEventLog _
("c:\scripts\" & objLogFile.LogFileName
& ".evt")
objLogFile.ClearEventLog()
End If
Next
 
C

Carrie Garth \(MVP\)

Hi James,

You may want to try posting in a scripting newsgroup such as *.scripting.wsh

For access to the newsgroup via the Microsoft Communities Web Interface, try this URL
http://communities.microsoft.com/Ne...D=US&newsgroup=microsoft.public.scripting.wsh

For those who read newsgroups using a NNTP newsreader, such as Outlook Express, and
use the msnews.microsoft.com news server, here is a link:
news://msnews.microsoft.com/microsoft.public.scripting.wsh

Also, for a way to... . . .

- More easily find, read, post, and reply to, messages
- Organize and manage messages using folders, views, rules, etc.
- Easily find newsgroups of interest by entering text to search through the Microsoft
Public News Server's list of thousands of newsgroups dedicated to Microsoft
products

.. . . .... instead of accessing the Microsoft Public Newsgroups using the Web
Interface, consider using a newsreader such as Microsoft Outlook Express. For a Web
Page that includes instructions for setting up an account in Microsoft Outlook
Express that connects directly to the free Microsoft Public News Server, see the
following Web Page:

Internet Explorer Newsgroup Setup Instructions
http://www.microsoft.com/windows/ie/support/newsgroups/howto.asp

--
Carrie Garth, Microsoft MVP for Windows 2000
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- c x g

"james" <james AT icondesigns DOT com DOT ph>
: Wrote in message : Sent: Thursday, July 10, 2003 02:46 PM
: I am new to scripting using WScript/Cscript. When I run
: the script to Backing Up and Clearing Event Logs If the
: Log Meets Specific Conditions i get the following error:
: ->terminated entity reference - matching ';' not found
:
: I have successfully loaded Windows Script V5.6 on a
: Windows NT 4.0 Build 1381. I need this script to run
: successfully on Windows 2000.
:
: Script below:
:
: strComputer = "."
: Set objWMIService = GetObject("winmgmts:" _
: & "{impersonationLevel=impersonate, (Backup,
: Security)}!\\" _
: & strComputer & "\root\cimv2")
: Set colLogFiles = objWMIService.ExecQuery _
: ("SELECT * FROM Win32_NTEventLogFile")
: For Each objLogfile in colLogFiles
: If objLogFile.FileSize > 20000000 Then
: strBackupLog = objLogFile.BackupEventLog _
: ("c:\scripts\" & objLogFile.LogFileName
: & ".evt")
: objLogFile.ClearEventLog()
: End If
: Next
: -------
:
: James
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top