programmatically determine real 8.3 name of a given folder in Win9x/ME

Discussion in 'Scripting' started by David H. Lipman, Jul 2, 2005.

  1. Say for example the folder 'C:\Program Files'.

    How can you programmatically determine the real 8.3 name of the folder.
    I don't want to make assumptions like c:\progra~1.
     
    David H. Lipman, Jul 2, 2005
    #1
    1. Advertisements

  2. Hi,

    The Folder object in FileSystemObject has a ShortName property (same for the
    File object). They also have a ShortPath property.

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder("c:\Program Files")
    Wscript.Echo objFolder.ShortName
    Wscript.Echo objFolder.ShortPath

    Set objFile = objFSO.GetFile("c:\Program Files\Long Name.txt")
    Wscript.Echo objFile.ShortName
    Wscript.Echo objFile.ShortPath
     
    Richard Mueller [MVP], Jul 2, 2005
    #2
    1. Advertisements

  3. From: "Richard Mueller [MVP]" <>


    |
    | Hi,
    |
    | The Folder object in FileSystemObject has a ShortName property (same for the
    | File object). They also have a ShortPath property.
    |
    | Set objFSO = CreateObject("Scripting.FileSystemObject")
    | Set objFolder = objFSO.GetFolder("c:\Program Files")
    | Wscript.Echo objFolder.ShortName
    | Wscript.Echo objFolder.ShortPath
    |
    | Set objFile = objFSO.GetFile("c:\Program Files\Long Name.txt")
    | Wscript.Echo objFile.ShortName
    | Wscript.Echo objFile.ShortPath
    |
    | --
    | Richard
    | Microsoft MVP Scripting and ADSI
    | Hilltop Lab web site - http://www.rlmueller.net
    | --
    |

    Thank you !

    Now I have try to recode this using Kixtart.
     
    David H. Lipman, Jul 2, 2005
    #3
  4. From: "Richard Mueller [MVP]" <>

    | Hi,

    | The Folder object in FileSystemObject has a ShortName property (same for the
    | File object). They also have a ShortPath property.

    | Set objFSO = CreateObject("Scripting.FileSystemObject")
    | Set objFolder = objFSO.GetFolder("c:\Program Files")
    | Wscript.Echo objFolder.ShortName
    | Wscript.Echo objFolder.ShortPath

    | Set objFile = objFSO.GetFile("c:\Program Files\Long Name.txt")
    | Wscript.Echo objFile.ShortName
    | Wscript.Echo objFile.ShortPath

    | --
    | Richard
    | Microsoft MVP Scripting and ADSI
    | Hilltop Lab web site - http://www.rlmueller.net

    Thanx a bunch Richard. The following test Kixtart script works well !

    SETCONSOLE("SHOW")
    SETCONSOLE("MAXIMIZE")
    SETCONSOLE("FOREGROUND")
    $LongPath="C:\Program Files\Internet Explorer"
    $objFSO=CreateObject("Scripting.FileSystemObject")
    $objFolder=$objFSO.GetFolder($LongPath)
    $Shortpath=$objFolder.ShortPath
    cls
    ? "The 8.3 Path of... "+$LongPath
    ? "is ... "+$Shortpath
    sleep 10
     
    David H. Lipman, Jul 2, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.