When you need to use an object, it must first be instantiated. For example:
Set objFSO = CreateObject("Scripting.FileSystemObject")
This example uses the FileSystemObject to allow access to files, folders, drives and text files.
Dim objFSO, objFolder, objFile, objNewFolder Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("C:\scripts\") Set objNewFolder = objFSO.CreateFolder("C:\Test") For Each objFile In objFolder.Files objFile.Copy "C:\test\" Next
The above script will create a folder called "Test" on the C: Drive and copy the contents of the C:\Scripts folder into the new test folder.
For more information about VBScript, check out our VBScript Training Videos