As you just need one element (folder) from the collection (SubFolders), sorting is overkill. But you need to convert the folder name into something (correctly) sortable. This subtask is addressed in the answers is linked to.
The conversion can be done by formatting (padding) the parts of the folder names:
Option Explicit
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim oSB : Set oSB = CreateObject("System.Text.StringBuilder")
Dim sLst : sLst = "" ' smallest possible value
Dim oLst : Set oLst = Nothing
Dim oDir
For Each oDir In oFS.GetFolder("..\f").SubFolders
Dim aParts : aParts = Split(oDir.Name, ".")
ReDim Preserve aParts(3)
oSB.AppendFormat_4 "{0,6}{1,6}{2,6}{3,6}", (aParts)
Dim sKey : sKey = oSB.ToString() : oSB.Length = 0
If sLst < sKey Then
sLst = sKey
Set oLst = oDir
End If
Next
If Not oLst Is Nothing Then
WScript.Echo "latest:", oLst.Name
End If
output:
cscript 31720684.vbs
latest: 15.0.4727.1002
Update wrt comment:
By setting oLst
to Nothing before the loop, I can test it after the loop to guard against an empty/no subfolders directory. Or: If I want to use oLst.Name
I should make sure that oLst
is an (usable) object.