RE: newbie problem - how do I get dll version & size?



You can avoid 1, 2, and 3 by assigning the text returned from ReadLine to a
variable and then performing your operations on that variable. You can also
use ObjTextFile1.AtEndofStream to test for the end of the file instead of
specifying the exact number of lines in the input file.

As you have it now it's reading 2 lines from the input file each time
through the loop and eventually tries to read past the end of the file.
If inStr(objTextFile1.Readline, ",") Then 'This will read the first line of
the file and check for a comma
arrDLLRec = split(objTextFile1.Readline, ",") 'This will read the
second line and split it


Here's what should be a working example, left mostly the way you had it:
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFSO.OpenTextFile("input.txt", ForReading)
Set objOutputFile = objFSO.CreateTextFile("output.txt")
'
Do While Not objInputFile.AtEndofStream
tmp = objInputFile.ReadLine
If inStr(tmp, ",") Then
arrDLLRec = split(tmp, ",")
filepath = arrDLLRec(0) & "\" & arrDLLRec(1)
If objFSO.FileExists(filepath) Then
Set objFile = objFSO.GetFile(filepath)
objOutputFile.WriteLine "(" & _
objFile.Name & ")..(" & _
objFSO.GetFileVersion(filepath) & ")..(" &_
objFile.Path & ")..(" & objFile.size & ")"
Else
objOutputFile.Writeline filepath & " does not exist."
End If
Else
objInputFile.Skipline
End If
Loop

objInputFile.Close
objOutputFile.Close

"Tcs" wrote:

> My original post from yesterday in microsoft.public.windowsxp.wmi. Since I've
> received no response, I'll try here.
>
> ============================================================================
> I have a bunch of machines on which I need to check .dll revisions. I'm trying
> to write a simple(?) script to do this. here's what I have so far:
>
> '---------------------------------------------------------------------------
> strComputer = "."
> Set objFSO = CreateObject("Scripting.FileSystemObject")
>
> strNames = & _
> "c:\winnt\regedit.exe," & _
> "c:\winnt\explorer.exe"
>
> arrNames = Split(strNames, ",")
> Wscript.Echo Ubound(arrNames) + 1
>
> Set objTextFile = objFSO.CreateTextFile("IT-DBAdmin_Jet_40_SP8_files.txt")
>
> Do While NOT Ubound(arrNames) = ""
>
> Wscript.Echo "(regedit.com)...(" & _
> objFSO.GetFileVersion("c:\winnt\regedit.exe") & ")" & _
> objFSO.FileSize("c:\winnt\regedit.exe") & ")"
>
> Wscript.Echo "(explorer.exe)...(" & _
> objFSO.GetFileVersion("c:\winnt\explorer.exe") & ")" & _
> objFSO.FileSize("c:\winnt\explorer.exe") & ")"
>
> Loop
>
> objTextFile.Close
> '---------------------------------------------------------------------------
>
> And of course it doesn't work. I would *like* to set up an array of the
> filenames I want info on, then cycle thru them until the list is finished. I'd
> *also* like to write this info out to a file.
>
> You can see that I have "pieces", just not the whole thing, plus my DO loop
> isn't good. And my 'objFSO.FileSize' doesn't work as well. (Geez. But hey, I
> only started with this wmi scripting about 2 hours ago... Really.) If i can't
> cycle thru an array of the names I need, how would I set a path, so I cane save
> some typing? (Since a lot of these are in the same place, such as
> "C:\Winnt\system32".)
>
> If anyone could "fill in the gaps", or point me to some where I might find what
> I'm after, I'd appreciate it.
>
> Thanks in advance,
>
> Tom
> ============================================================================
>
> Since then I've made mods to this:
>
> My input file:
>
> c:\Program Files\Common Files\Microsoft Shared\DAO,Dao360.dll,3.60.8025.0,557328
> c:\winnt\system32,Expsrv.dll,6.0.72.9589,380957
> c:\winnt\system32,Msexch40.dll,4.0.6807.0,512272
> c:\winnt\system32,Msexcl40.dll,4.0.8015.0,303376
> c:\winnt\system32,Msjet40.dll,4.0.8015.0,1507600
> c:\winnt\system32,Msjetoledb40.dll,4.0.8015.0,348432
> c:\winnt\system32,Msjint40.dll,4.0.6508.0,151824
> c:\winnt\system32,Msjter40.dll,4.0.6508.0,53520
> c:\winnt\system32,Msjtes40.dll,4.0.8015.0,241936
> c:\winnt\system32,Msltus40.dll,4.0.6508.0,213264
> c:\winnt\system32,Mspbde40.dll,4.0.8015.0,356624
> c:\winnt\system32,Msrd2x40.dll,4.0.7328.0,422160
> c:\winnt\system32,Msrd3x40.dll,4.0.6508.0,315664
> c:\winnt\system32,Msrepl40.dll,4.0.8015.0,553232
> c:\winnt\system32,Mstext40.dll,4.0.8015.0,258320
> c:\winnt\system32,Mswdat10.dll,4.0.6508.0,831760
> c:\winnt\system32,Mswstr10.dll,4.0.6508.0,614672
> c:\winnt\system32,Msxbde40.dll,4.0.8025.0,360720
> c:\winnt\system32,Vbajet32.dll,6.0.1.9431,30749
>
> My script:
>
> strComputerName = "."
>
> Const ForReading = 1
>
> intFilesToChk = 19
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile1 = objFSO.OpenTextFile("Jet_40_SP8_Files.txt", ForReading)
> Set objTextFile2 = objFSO.CreateTextFile("ITGUY_Jet_40_SP8_files.txt")
>
> Wscript.Echo " " & _
> " Filename version filesize "
> Wscript.Echo " " & _
> "-----------------------------------------------------------"
>
> '
> ' first show me what I'm *supposed* to have
> '
> For L1 = 1 to intFilesToChk Step 1
> If inStr(objTextFile1.Readline, ",") Then
> arrDLLRec = split(objTextFile1.Readline, ",")
> Wscript.Echo "(" & _
> arrDLLRec(0) & ")..(" & _
> arrDLLRec(1) & ")..(" & _
> arrDLLRec(2) & ")..(" & _
> arrDLLRec(3) & ")"
> Else
> objTextFile1.Skipline
> End If
> i = i + 1
> Next
> objTextFile1.Close
>
> objTextFile2.Skipline
>
>
> Set objTextFile1 = objFSO.OpenTextFile("Jet_40_SP8_Files.txt", ForReading)
>
> '
> ' now show me what's actually on this machine
> '
> For L1 = 1 to intFilesToChk Step 1
> If inStr(objtextFile1.Readline, ",") Then
> arrDLLRec = split(objTextFile1.Readline, ",")
> Set objFile = objFSO.GetFile(arrDLLRec(0) & "\" & arrDLLRec(1))
> ' Wscript.Echo "(" & _
> ' objFile.Name & ")..(" & _
> ' objFile.Version & ")..(" & _
> ' objFile.size & ")"
> Wscript.Echo "(" & _
> objFile.Name & ")..(" & _
> objFSO.GetFileVersion(arrDLLRec(0) & "\" & arrDLLRec(1)) & ")..(" &
> _
> objFile.Path & ")..(" & _
> format(int(objFile.size), "#,##0") & ")"
> Else
> objTextFile1.Skipline
> End If
> i = i + 1
> Next
> objTextFile1.Close
> objTextFile2.Close
>
> Problem #1.) Line 1 of my input file seems to be skipped. Perhaps because of
> the several spaces in the path? How do I fix it? (Enclosing the path in quotes
> didn't help.)
>
> Problem #2.) Line 19, Char 9, Subscript out of range: '[number: 0]'. This
> occurs after displaying the next to the last line of the input file.
> ALTHOUGH...when I see it, this line is only the 9th filename I've seen, not the
> 18th, as it should be.
>
> Problem #3.) I took out line 1 of my input file, so I could see if the space
> affected the result. Problem #2 disappeared. But now I have another. 'Input
> past end of file.' Even if I reduce my counter, I still get this. I've reduced
> my counter to 15, but I still get an error when I try to read the 10th record.
>
> Problem #4.) When the line number is reported, does this mean the 'actual' line
> number of the script, including blank lines? Or just the line number of lines
> with code?
>
> Sorry for the looong post, and so many questions. I'm just getting started with
> this wmi scripting and have no one else to ask. Thanks for your indulgence.
>
> Thanks in advance,
>
> Tom
>
>
>
>
.



Relevant Pages

  • Re: Really Baffled any clues as to what is going on?
    ... > I am working on a script, it has an input file of machine names. ... > Dim fstrLogFilePath ... > fstrInputFile = InputBox("Enter name of file containing machines to ...
    (microsoft.public.scripting.vbscript)
  • Re: Need help understanding how a file input block works
    ... I need to understand how a particular script works and am having ... here is a sample of the input file: ... here is a section of the Perl code that I am having ... line 3 starts a loop that goes through each line in the input file ...
    (comp.lang.perl.misc)
  • Re: Parse an input file using a Key value
    ... I have an input file in the following format getting repeated. ... I tried to achieve this task using the following script below but it is ... To tranpose certain rows into columns and sort by one of the ...
    (comp.unix.shell)
  • Re: Running a DOS program using Microsoft Command Shell
    ... needed are available by public FTP: ... and the input file is run.txt. ... missing the ESC character, since I don'y know how to feed ESC in this ... When instructed from shell script, the progam simply ignores all SendKeys. ...
    (microsoft.public.windows.server.scripting)
  • newbie problem - how do I get dll version & size?
    ... I have a bunch of machines on which I need to check .dll revisions. ... to write a simplescript to do this. ... Set objFSO = CreateObject ... Line 1 of my input file seems to be skipped. ...
    (microsoft.public.scripting.vbscript)

Loading