i

GetFileName Method


Returns the last component of specified path that is not part of the drive specification.


Function GetAName(DriveSpec)

   Dim fso

   Set fso = CreateObject("Scripting.FileSystemObject")

   GetAName = fso.GetFileName(DriveSpec)

End Function


solution I found interesting from MS TechNet less customization but gets what you wanted to achieve. This returns the full path of the selected file.


Set wShell=CreateObject("WScript.Shell")

Set oExec=wShell.Exec("mshta.exe ""about:<input type=file id=FILE><script>FILE.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>""")

sFileSelected = oExec.StdOut.ReadLine

wscript.echo sFileSelected