I was looking for a way to do a head in Windows and didn’t want to use any third-party software and of course, it had to be on the commandline.  So like head I needed it to show X number of lines from the beginning.  I don’t know VBScript, so I am sure there is a better/cleaner way to write this but here is what I came up with.  If anyone knows an easier way please pass it on.

If WScript.Arguments.Count = 2 Then
FileName = WScript.Arguments.Item(0)
NumLines = WScript.Arguments.Item(1)
Else
Wscript.Echo "Usage: cscript.exe head.vbs filename NumberOfLines"
Wscript.Quit
End If

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(FileName, ForReading)

Dim i
For i = 1 To NumLines
strNextLine = objFile.ReadLine
strLine = strNextLine
Wscript.Echo strLine
Next

objFile.Close
C:\dumps>type test.txt
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
C:\dumps>cscript //nologo head.vbs test.txt 8
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8