'This Example Demonstrates How To Use The "GetExtensionName" Method To
'Get The File Extension Of The Last Component In A Specified Path.
Dim Fso, FileExtension
Set Fso = CreateObject("Scripting.FileSystemObject") 'Creates "FileSystemObject" Object.
FilePath = InputBox("Enter Full Path Of The File : ","File Path") 'Get Path Of The File
FileExtension = Fso.GetExtensionName(FilePath) 'Returns Extension Of The Specified File.
MsgBox "Extension Of : " & FilePath & " Is - " & FileExtension
=====================================================================
Sub wOut(Var)
on error resume next
Wscript.StdOut.Write(Var)
End Sub
on error resume next
vPath = Wscript.Arguments(0)
vOption = Wscript.Arguments(1)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set vFile = FSO.GetFile(vPath)
vFilename = FSO.GetBaseName(vPath)
vExtension = FSO.GetExtensionName(vPath)
vType = vFile.Type
Select case vOption
case "filename": wOut(vFilename)
case "extension": wOut(vExtension)
case "type": wOut(vType)
End Select
if err <> 0 then wOut("")
On error goto 0