Re: Count lines in another VBS file
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 23 Jul 2008 20:42:14 -0500
"XP" <XP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9A8CC378-D10D-4DE8-A487-C4EB3786CFD6@xxxxxxxxxxxxxxxx
I would like to code a VBS file that counts all the lines in another VBS
file
by adding a CONST to the full file name of the target.
Can someone help me with that?
Thanks much in advance.
Maybe you want to pass the filename and path of the "target" *.vbs files as
an argument to the VBScript program. If so, the code posted previously could
be revised as follows to accept an argument:
==========
' Make sure one argument passed to the program.
If (Wscript.Arguments.Count <> 1 0) Then
Wscript.Echo "Require argument missing"
Wscript.Quit
End If
' Read the first argument (index 0).
strFile = Wscript.Arguments(0).
Set FSO = CreateObject("Scripting.FileSystemObject")
Set inFile = FSO.OpenTextFile(strFile)
lines = Split( inFile.ReadAll, vbLF )
lineCount = UBound(lines) ' assumes last line ends with line break
Wscript.Echo "Number of lines: " & lineCount
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: Count lines in another VBS file
- From: Tom Lavedas
- Re: Count lines in another VBS file
- References:
- Count lines in another VBS file
- From: XP
- Count lines in another VBS file
- Prev by Date: RE: Count lines in another VBS file
- Next by Date: Re: FolderExists and UNC path
- Previous by thread: RE: Count lines in another VBS file
- Next by thread: Re: Count lines in another VBS file
- Index(es):
Relevant Pages
|