Can someone tell me what is wrong with this script?

Home Forums Scripting General Scripting Can someone tell me what is wrong with this script?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    tonyyeb
    Member
    #103297
    Code:
    strComputer = “.”
    const forwriting = 2
    set objfso = createobject(”Scripting.filesystemobject”)
    set objfile = objfso.opentextfile(”c:deletemp3.bat”, forwriting)
    set objwmiservice = getobject (”winmgmts:{impersonationlevel=impersonate}!\” & strComputer & “rootcimv2″)
    set colfiles = objwmiservice.execquery (”Select *from CIM_Datafile where extension = ‘mp3′”)
    for each objfile in colfiles
    var = objfile.name
    wscript.echo var
    objfile.write var
    Next
    objfile.close

    It lists all the mp3’s on my computer (and yes I have already got a file called deletemp3.bat in my c: drive) but it wont write the results of the file scan to my text file!

    I get this error:

    Code:
    C:Documents and SettingsChrisDesktopfilefinder.vbs(12, 1) Microsoft VBScript runtime error: Object doesn’t support this property or method: ‘objfile.write’

    But i can put a string into a variable and it writes that!! Hmmm!??

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.