VBscript error Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate, (Backup, Security)}!\\" & strComputer & "\root\cimv2")

Posted on 2006-05-09
Last Modified: 2012-06-21
I have written a script to backup and clear the windows event log daily. The script is as follows. So far I have encountered 2 errors. The first one is out of memory which I resolved after rebooting the server. The second error I received recently is "the RPC server is too busy to complete this operations". I have also placed this script in a number of other servers and they are running fine.

strComputer = "."
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strDirPath = "c:\audit\"

strDate = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
strCSV = strDirPath & "csv\" & strDate & "_Security.csv"
strEVT = strDirPath & "logs\" & strDate
strEVTSecurity = strDirPath & "logs\" & strDate & "_Security.evt"

'The error always return from this line. It seems like there is a memory issue here
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate, (Backup, Security)}!\\" & strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery ("Select * from Win32_NTEventLogFile")

'Backup log in log directory folder and clear all logs in win32
For Each objLogfile in colLogFiles
     objLogFile.BackupEventLog(strEVT & "_" & objLogFile.LogFileName & ".evt")

' Running the LogParser to process evt to csv
' EventID = 680 is for local
' EventID = 673 is for domain
strParm = "LogParser -i:EVT -o:CSV ""SELECT TO_DATE(TimeGenerated), TO_TIME(TimeGenerated), EventTypeName, EventCategoryName, EXTRACT_TOKEN(Strings, 0, '|'), EXTRACT_TOKEN(Strings, -1, '|'), ComputerName INTO "
strFullParm = strParm & strCSV & " FROM " & strEVTSecurity & " WHERE EventID = 673"
Set WshShell = WScript.CreateObject("WScript.Shell")
Question by:dc-ops
    1 Comment
    LVL 2

    Accepted Solution

    The RPC service on Windows is notoriously unreliable.  Generally if it fails, it's worth trying again; if not, unfortunately on Windows you're relatively stuck.  You could maybe try any hotfixes etc and make sure your server is up to date (I don't know of a specific one that is known to fix this sort of problem).  Other than that, I'll pass this over to the room...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Problem with Pie chart in Jsp 20 157
    proper way to parse text with delphi 7 77
    Opening a Access Database 5 104
    noX challenge 17 54
    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    This video teaches viewers about errors in exception handling.
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now