Using the Scripting Runtime Engine's FileSystemObject

The FileSystemObject of the Scripting Runtime Engine (Scrrun.dll) simplifies many common chores and provides better performance than some of the intrinsic Visual Basic functions.  Using the FileSystemObject you can:

  • Copy, create, move and delete files and folders
  • Test the existence of files and folders
  • Retrieve information such as file or folder name, path, short name, attributes, parent, size,...
  • Extract information about drives and shares attached to the system
  • Create, read and write text files and much more.

The sample code demonstrates most of the file operations. Performing corresponding folder operations is similar. For portability purposes, this project uses late binding and does not set a reference to the Microsoft Scripting Runtime Engine (Scrrun.dll).  However, by referencing this dll in the Project | References dialog, you can use the Object Browser to view all available properties and methods.

Performing file system operations is now as simply as instantiating an object and setting or examining properties. There are still instances where you may need to use traditional file processing methods and my File Operations sample may be of interest. But in many cases the FileSystemObject will suffice.

Download Source Code

Drive Information

This program uses the FileSystemObject to retrieve the following information about any drive or share attached to your computer:


Drive Info


Folder Data

Total disk size

Drive Type (fixed, removable...)

Volume Name

Root path

Available disk space

File system (Fat16, Fat32, NTFS)

Device or share name

Number of sub folders

Free disk space


Serial Number


Folder Information

A wealth of folder information is available including:

Name and Path


Full path name

Root folder or not

Short path name

Number of sub folders

Folder name

Number of files

Short folder name

Folder size in bytes


Last modified date

File Information

Here is some of the file information provided:

Name and Path


Full path name

Date created

Short path name

Date modified

Folder name

Date accessed

Short folder name

Size in bytes

Parent folder path

Attributes (R/O, Archive,...)


File type

Applies To

PC's with the Scrrun.dll installed. This file can be obtained by installing a recent version of Visual Studio, Visual Basic, Windows Scripting Host, Windows 98 or 2000. It can also be downloaded from Microsoft's site if you look under Scripting.


Download the source code. Run the sample by pressing F5.

To examine drive information:

  • Click the See Drive Info button
  • Select a drive letter from the drop down. Drive details are displayed in the lower frame.

To view folder information:

  • Click the See Folder Info button.
  • Navigate to the desired folder. Once the folder's path is displayed, click the Show Details button. Information for the folder is shown in the Folder Information frame. If the folder contains files, they will be listed in the File Information listbox.
  • Select a file from the File Information listbox to see its attributes.

To Copy, Move or Delete a File:

  • Click the File Operations button
  • To copy, move or delete a file, enter its path in the Source File field.
  • To copy or move a file, enter the destination path in the destination field
  • Press the appropriate button.

To Write a Text File and Read Back the results:

  • Click the File Operations button
  • Enter a file with a .txt extension and its path in the Source File field.
  • Click the Write/Read Back File button.
  • The file you specified will be created and you can examine it with Notepad.

About TheScarms
About TheScarms

Sample code
version info

If you use this code, please mention ""

Email this page

© Copyright 2016 TheScarms
Goto top of page