Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Get DOS 8.3 short name with VbScript

, 3 May 2010
Rate this:
Please Sign up or sign in to vote.
Create a new text file called shortname.vbs:Open in Notepad and paste the following code in it:set fso = CreateObject("Scripting.FileSystemObject") strLongName = Wscript.Arguments(0)strShortName = "Invalid File/Folder - (" & strLongName & ")"Set fsoFile = NothingOn Error Resume...
Create a new text file called shortname.vbs:
Open in Notepad and paste the following code in it:
 
set fso = CreateObject("Scripting.FileSystemObject") 
 
strLongName = Wscript.Arguments(0)
strShortName = "Invalid File/Folder - (" & strLongName & ")"
Set fsoFile = Nothing
 
On Error Resume Next
 
Set fsoFile = fso.GetFile(strLongName)
 
if Err.number <> 0 then
	Set fsoFile = fso.GetFolder(strLongName)
end if
 
if fsoFile is not nothing then
	strShortName = fsoFile.ShortPath
end if
Wscript.Echo strShortName
 
Run the script using cscript:
 
cscript shortname.vbs "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
You will then get the following output:
C:\PROGRA~1\Adobe\READER~1.0\Reader\AcroRd32.exe

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Riaan Lehmkuhl
Software Developer adhdForge
South Africa South Africa
Me, a disorder of the brain that results in a disruption in a person's thinking, mood, and ability to relate to others.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 3 May 2010
Article Copyright 2009 by Riaan Lehmkuhl
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid