Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Operating Systems .: Windows Operating Systems .: Windows Scripts and Batch Files .: VBScript to ArchiveEventLogs

VBScript to ArchiveEventLogs

The ArchiveLogs WSH package file is a framework for building collections of related jobs. A WSF package exists as an XML document. This format allows multiple related or unrelated scripts to be stored in teh same file. What it lacks is the concept of an embedded library of functions shared across all jobs in the file. By adding a simple function we can leverage this XML file to contain numerous library scripts.

------------------------------------------------------------------------------------------------------------------------------

On error resume next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://DC=DOMAIN,DC=local' " _
        & "Where objectClass='computer'" 
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
   
    ' Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
    strComputer = objRecordSet.Fields("Name").Value
   
    Set objShell = CreateObject("WScript.Shell")
    strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
    Set objExecObject = objShell.Exec(strCommand)

'clears echo replies left in strText from the previous loop
strText=""


Do While Not objExecObject.StdOut.AtEndOfStream
        strText = objExecObject.StdOut.ReadAll()
        If Instr(strText, "Reply") > 0 Then


            Set objWMIService = GetObject _
                ("winmgmts:\\" & strComputer & "\root\cimv2")
      Set colItems = objWMIService.ExecQuery _
                ("Select * From Win32_OperatingSystem") 
     Set colItems2 = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
           ' Wscript.Echo Err.Description
     Set colItems3 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
     Set colItems4 = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

     For Each objItem in ColItems
                strOS = objItem.Caption
     Next
  
     For Each objItem in colItems2
  strDellTag = objItem.SerialNumber
  strManu = objItem.Manufacturer
     Next

     For Each objItem in colitems3
         strUserName = objItem.Username
  strModel = objItem.Model
  strRAM = objItem.TotalPhysicalMemory
  strTimeZone = (objItem.CurrentTimeZone / 60)
  strDayLightSavings = objItem.DaylightInEffect
     Next
 
     For Each objItem in colitems4
  strProcessor = objItem.Name
            Next
  
  If Err.Number > 0 then
    strErrorSystems =  strComputer & ", " & strErrorSystems
  else
    Wscript.Echo "-------------------------------------------------------------"
    Wscript.Echo "Computer Name: " & strComputer & ", " & strUserName
    Wscript.Echo "-------------------------------------------------------------"
           Wscript.Echo "Operating System: " & strOS
                  Wscript.Echo "Current User: " & strUserName
    Wscript.Echo "::::"
    WScript.Echo "Manufacturer: " & strManu
    Wscript.Echo "Model: " & strModel
    Wscript.Echo "Dell Service Tag: " & strDellTag
    Wscript.Echo "Processor type: " & strProcessor
    Wscript.Echo "RAM: " & strRAM
    Wscript.Echo "Time Zone: " & strTimeZone
    Wscript.Echo "Daylight Savings in effect: " & strDayLIghtSavings
    Wscript.Echo "-------------------------------------------------------------"

  end if
  
      
     'flushes error code from the previous loop
     Err.Clear
    
  
            '

        Else
            '
      UnavailableSystems =  strComputer & ", " & UnavailableSystems

    End If
    Loop

  
    objRecordSet.MoveNext
Loop

Wscript.Echo "The following systems were unavailable: " & UnavailableSystems
Wscript.Echo " "
Wscript.Echo "The following systems were on, but returned an error: " & strErrorSystems


How helpful was this article to you?

Related Articles

article Using VBScript for CD Autorun
i found that starting a VBScript from an...

(No rating)  3-24-2008    Views: 114   
article Have the VBScript check to see if it is being run with CScript or WScript
Option ExplicitDim Script,...

(No rating)  3-24-2008    Views: 119   
article VBScript to List Network Shares
This script will interrogate the operating...

(No rating)  5-1-2008    Views: 138   

User Comments

Add Comment
No comments have been posted.