script runs against 2003, but not 2000

Discussion in 'Scripting' started by Breck, Jun 10, 2004.

  1. Breck

    Breck Guest

    Hi all,

    I'm fairly new to wmi scripting, but I'm trilled with the possibilities.
    I'm running this following script from 1 server (2003 machine) and it looks
    to servers.txt for a list of all our servers to loop thru checking free
    space of the drives. The problem I'm having is the script will error out
    when it hits any 2000 machine. I've installed the latest version of the wmi
    service on those 2000 machines.

    Here is the error:
    E:\batchfiles\drivereport.vbs(35, 5) (null): 0x80041010

    doing a search around for the 80041010 error I found mention that this is
    caused by a misspelled object name, if that is the case have the object
    names from 2000 to 2003 changed? where is a good reference for the 2
    different set of object names. Or am I getting this error perhaps b/c of
    some security issue? Or any other clues as to what is happening?

    The servers being accesesed in this script are not on a domain, but all the
    admin usernames and passwords are the same, and the script runs fine on 2003
    servers.

    01: Const INPUT_FILE_NAME = "E:\batchfiles\servers.txt"
    02: Const FOR_READING = 1
    03:
    04: Dim FileSystemObj
    05: Dim msg
    06: Dim tmsg
    07: Dim i
    08: Dim drvflag
    09: Dim emailflag
    10: Dim target
    11:
    12: Set objDictionary = CreateObject("Scripting.Dictionary")
    13: Set objFSO = CreateObject("Scripting.FileSystemObject")
    14: Set objTextFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
    15: i=0
    16: drvflag = 0
    17: emailflag = 0
    18: target = WScript.Arguments(0)
    19: msg = "DRIVE SPACE REPORT" & vbCRLF
    20: msg = msg & "Drive - Free MB - % Free" & vbCRLF
    21:
    22: Do While objTextFile.AtEndOfStream <> True
    23: strNextLine = objTextFile.Readline
    24: objDictionary.add i, strNextLine
    25: i = i + 1
    26: Loop
    27:
    28: For Each objItem in objDictionary
    29: WScript.Echo objDictionary.Item(objItem)
    30:
    31: Set objWMIService = GetObject("winmgmts:" &
    "{impersonationLevel=impersonate}!\\" & objDictionary.Item(objItem) &
    "\root\cimv2")
    32: Set colDiskDrives = objWMIService.ExecQuery ("Select * from
    win32_perfformatteddata_perfdisk_logicaldisk where Name <> '_Total'")
    33:
    34: 'check each drives free space
    35: For each objDiskDrive in colDiskDrives
    36: If objDiskDrive.PercentFreeSpace < Cint(target) then
    37: drvflag = 1
    38: tmsg = tmsg & objDiskDrive.Name & " - "
    39: tmsg = tmsg & objDiskDrive.FreeMegabytes & " - "
    40: tmsg = tmsg & objDiskDrive.PercentFreeSpace & vbCRLF
    41: End if
    42: Next
    43:
    44: 'check for computer info for drives if true write it
    45: If drvflag = 1 then
    46: msg = msg & "=====" & objDictionary.Item(objItem) & "=====" &
    vbCRLF
    47: msg = msg & tmsg
    48: emailflag = 1
    49: drvflag = 0
    50: end if
    51: tmsg = ""
    52: Next
    53:
    54: If emailflag = 1 then
    ..
    ..
    ..
    'code to send email

    ======

    Thanks in advanced for any help or direction.
     
    Breck, Jun 10, 2004
    #1
    1. Advertisements

  2. Patrick Ogenstad, Jun 11, 2004
    #2
    1. Advertisements

  3. Breck

    Breck Guest

    Thanks for the link and info for the newbie here.
     
    Breck, Jun 11, 2004
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.