Loop through the items in a collection or array.
Syntax For Each element In Group [Statements] [Exit For] [Statements] Next [element] Key element A variable used to hold each item in the group Group A collection or a VBScript array
Set objFSO = CreateObject("Scripting.FileSystemObject") For Each objDrive In objFSO.Drives WScript.Echo objDrive.DriveType Next Set objFolder = objFSO.GetFolder("C:\Work") Set arrFolders = objFolder.SubFolders For Each strFolderName In arrFolders WScript.Echo strFolderName Next
“Profit in business comes from repeat customers, customers that boast about your project or service, and that bring friends with them” ~ W. Edwards Deming
For...Next - Repeat a block of statements a given number of times
Do..Loop - Repeat a block of statements
Equivalent Powershell command: ForEach-Object