File It Under Files

In your first file system script, Listfiles.vbs, you connect to FileSystemObject, attach it to a folder defined by the variable FolderPath, and then use the Files command to enable the For Each loop to echo out each file in the folder. This is just the beginning of what you can do with this script. Continue to think of ways to expand upon this script so that you can perform some really useful network administration tasks.

Option Explicit On Error Resume Next Dim FolderPath ' folder to be searched for files Dim objFSO Dim objFolder Dim colFiles Dim objFile FolderPath = "C:\scriptingBook\BookScripts_VbScript" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(FolderPath) Set colFiles = objFolder.Files ...

Get Microsoft® Windows® Scripting Self-Paced Learning Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.