Vbscript seek to end of file to make a tail command script


I've writen a simple tail command using vbscript. It works fine except for very large files where it has to read through the entire file to get the last 10 lines. Is there a way to seek to the end of the file and then read backwards for ten lines?


I am afraid that seeking backwards is impossible in VBS TextStream, but instead of reading through the entire file you can seek to a position eg. 1K before EOF and then read the rest of the file, displaying only the last 10 lines.

EDIT: I'm adding some sample code to illustrate the idea:

set fso = CreateObject("Scripting.FileSystemObject") set file = fso.GetFile(filePath) set stream = file.OpenAsTextStream(1, -2) pos1KBeforeEnd = file.Size-1024 if pos1KBeforeEnd<0 then pos1KBeforeEnd=0 stream.Skip pos1KBeforeEnd


  • SQL Server varchar(50) and varchar(128) performance difference [duplicate]
  • how to play a mp3 file from the middle
  • dynamic change of templateUrl in ui-router from one state to another
  • Vector Drawables in Layer List on Android API 16 and higher
  • What is the sql query for this?
  • Matlab to Python Conversion binary file read
  • WildCard for Object in Java6
  • how to force OCaml to infer a more general type?
  • request follow redirection without post data
  • Python: include entries of a dictionary in the local namespace of a function
  • Row_number() function for Informix
  • Collect and run all junit tests in parallel with each test class in its own JVM (parallelization by
  • How can I get process name of specific PID with ps command in alpine
  • Relationship between integers and their names - Prolog
  • Taking mean across rows grouped by a variable in numpy
  • Quickly or concisely determine the longest string per column in a row-based data collection
  • How to add specific media query rule when media query combined
  • MonadTransControl instance for ProxyFast/ProxyCorrect
  • Disabling sound of embedded flash object with html
  • Migration to HRD - How to convert string-encoded keys to new application
  • Detecting null parameter in preprocessor macro
  • DIV instruction jumping to random location?
  • Installed module is empty
  • Blackberry - Custom EditField Cursor
  • Cancel a live stream “fast motion” catch-up in Flash
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Body moving without any force applied? (Box2d)
  • R - Combining Columns to String Based on Logical Match
  • Read text file and split every line in MSBuild
  • PHP - How to update data to MySQL when click a radio button
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Return words with double consecutive letters
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • how to add data labels for bar graph in matlab
  • How to disable jQuery.jplayer autoplay?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • coudnt use logback because of log4j
  • Android Google Maps API OnLocationChanged only called once