Results 1 to 6 of 6

Thread: command line problem found but the fix could not be found

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Nepal
    Posts
    103

    command line problem found but the fix could not be found

    Yesterday I posted a question (which is still unanswered) regarding a command line problem in windowsNT. I found out what the problem was. Actually windows NT takes dos style file and foldernames, ie, if the pathname is "C:\program files\abc\abc.ntd" then in NT the pathname that is looked for is "C:\progra~1\abc\abc.ntd". Problem also occurs even with short names (within 8 characters) if they have space inside the name.

    Now the question is: what is the best way to convert the name like "program files" to dos style name eg"progra~1, without changing anything else. Is there any api ? Please help.

  2. #2
    New Member
    Join Date
    Apr 2003
    Posts
    9
    I always thought that NT converted/handled filenames for you, all you needed to do way place " around the filename

    I have several batch files running on NT to prove this.


    ShadeZ

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Nepal
    Posts
    103
    Well I thought so too, but i have my program itself to prove it wrong. & when I was looking for an answer I found two of them. one is given in MSDN, and another is for delphi, but as it includes an api, I think that api will work in vb too. The links are as follows:

    1. http://msdn.microsoft.com/archive/de...dn_msdn207.asp

    2. http://greatis.com/delphi/filesdirec...ame2short.html

    Anyway thanks for the response.

  4. #4
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    Yesterday I posted a question (which is still unanswered) regarding a command line problem in windowsNT. I found out what the problem was. Actually windows NT takes dos style file and foldernames, ie, if the pathname is "C:\program files\abc\abc.ntd" then in NT the pathname that is looked for is "C:\progra~1\abc\abc.ntd". Problem also occurs even with short names (within 8 characters) if they have space inside the name.
    I looked at your other thread, and am wondering if the short file names are coming through via Command$ (I'm guessing that this is being used after you click on the file name in the Windows Explorer--since you mentioned that you associated the file name). Is this right? If that's the case, just something you should know -- Windows nearly always uses the Short File name convention when passing data internally. I use Windows 2000 and this same things happens, however, your program should have no problem resolving the short file name. However, to answer your question, there is an API that will do what you ask. Its called GetLongPathName. Here is an example of how you would use it found here: http://www.vbforums.com/showthread.p...etLongFileName

    Just remember, this api is only present on Win98+ on the Win9x kernel and Win2000+ on the NT kernel.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Nepal
    Posts
    103
    Well I tried my program in windows 2000 itself. Then when I found the error, I wanted to know what is the path that is used. so I used:

    labelX.caption = command$

    which displayed: C:\Program files\abc\abc.ntd in labelx.

    Now I tried this in the Start>>Run:

    C:\progra~1\abc\myprog.exe C:\Program files\abc\abc.ntd

    This generates the same error, while,

    C:\progra~1\abc\myprog.exe C:\Progra~1\abc\abc.ntd

    does not generate such an error and opens the file smoothly.

  6. #6
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    C:\progra~1\abc\myprog.exe C:\Program files\abc\abc.ntd
    From the run command, spaces represent new arguments (and this is how the shell command treats them). If you want to run something with spaces from the run command, you have to quote it like:
    C:\progra~1\abc\myprog.exe "c:\program files\abc\abc.ntd"

    Internally, your program would have to parse these quotes, since they would come across via the command$ statement as:
    "c:\program files\abc\abc.ntd"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width