Can I grab the SFN(8.3) filename from an existing file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NyNyHelp
    New Member
    • Jul 2007
    • 21

    Can I grab the SFN(8.3) filename from an existing file.

    I am trying to run some batches through VB and when I try to run them through shell it cannot find them but I changed one of filenames to its short file name and it worked. So I want to be able to run a file as its short file name without having to look it up in Dos and change it manually.

    -John
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by NyNyHelp
    I am trying to run some batches through VB and when I try to run them through shell it cannot find them but I changed one of filenames to its short file name and it worked. So I want to be able to run a file as its short file name without having to look it up in Dos and change it manually.
    Details may vary depending on your VB version. But in general, use the File System Object model (check your doco) to access the file. The File object has a ShortName property which returns what you want.

    Comment

    • Macta
      New Member
      • Feb 2007
      • 6

      #3
      Filenames having length greater then 8 charactors or having spaces are not recognized by DOS. so what you have to do, is to Change the windows file path to a DOS recognizable path e.g

      E:\MY PROGRAMMING\COD E PROJECTS\ASM TEST.BAT ==> windows path
      E:\MYPROG~1\COD EPR~1\ASMTES~1. BAT ==> DOS Path

      I have written my own routines to get around this mess when i was working to develop an IDE for Assembly Language and it works like a dream. If you wish, i can give it to you.
      All the best.

      Comment

      • NyNyHelp
        New Member
        • Jul 2007
        • 21

        #4
        Originally posted by Macta
        Filenames having length greater then 8 charactors or having spaces are not recognized by DOS. so what you have to do, is to Change the windows file path to a DOS recognizable path e.g

        E:\MY PROGRAMMING\COD E PROJECTS\ASM TEST.BAT ==> windows path
        E:\MYPROG~1\COD EPR~1\ASMTES~1. BAT ==> DOS Path

        I have written my own routines to get around this mess when i was working to develop an IDE for Assembly Language and it works like a dream. If you wish, i can give it to you.
        All the best.
        Those routines would be greatly appreciated.

        Comment

        • NyNyHelp
          New Member
          • Jul 2007
          • 21

          #5
          I was calling my batches via the code below

          Dim shell
          shell = CreateObject("w script.shell")
          shell.run(batch path)
          shell = Nothing

          This seems to be a more DOS approach but I liked it because it opened each batch in a different dos window which was good for debugging with what I'm doing but this has trouble reading file names with spaces. The following code does not but runs all batches in one DOS window.

          Shell(batch Path)

          This solves my dilemma.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Cool!

            I think you'll find, though, that DOS (oops! Don't let M$ hear me use the "D word") does in fact support long filenames, and ones with gaps. It depends what version of DOS, I suppose. But generally speaking, they should work if you put "quotes around them".

            Comment

            Working...