Results 1 to 12 of 12

Thread: Need help with app.path

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149

    Arrow

    Hi,
    Just wondering if anyone can help me with a small problem.

    I am wanting to insert an app.path into a variable (say it is "application" ) but I want it to use the dos names of that not the full names.

    So what I mean is just say i do this:
    Code:
    application = app.path
    
    msgbox application
    That would return something like this:
    "c:\Program Files\Application Folder"

    but that is not what I want, I want it to return the dow names for the folders like this:
    "c:\progra~1\applic~1"


    Can anyone help me with this??

    Thanks

    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

  2. #2
    Jethro
    Guest

    Oh okay

    Don't think app will give it but could use the Split function to extract each file, then use Left fuction to grab the first six characters and append with ~1. Then paste em back together. Would also be interested if anyone has a sneaky way around this.

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    But what happens if you have a folder/file with almost the same name (like c:\mongoose and c:\mongoose eaters would become c:\mongoo~1 and c:\mongoo~2). That method wouldn't deal with that prob

    Why do you want the DOS name anyway? This is the age of 255 with spaces file names!!

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    that's what I was just thinking, Jethro...

    Code:
    Dim application As String
    Dim arrTemp As Variant
    
    application = App.Path
    
    arrTemp = Split(application,"\")
    
    For x = 0 To UBound(arrTemp)
      If Len(arrTemp(x)) > 6 Then
        arrTemp(x) = Left(arrTemp(x),6) & "~1"
      End If
    Next x
    
    application = Join(arrTemp,"\")
    
    MsgBox application
    see if that works
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    the problem with that is that not every windows system appends a ~1 after the first 6 letters, i remember an option in the control panel for win 95 that lets you decide if there is to be a ~1 after 6 characters or if it to be just made 8 characters then truncated.

    What I am realy looking for is something that will get the 8.3 format filename of the dir, if you right click on a dir and goto properties you will see a thing that says MS-Dos name, this is what i want, but I want to use the app path thing, cause the application could be installed in a different place each time.

    Ta for any help

    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by chrisjk
    But what happens if you have a folder/file with almost the same name (like c:\mongoose and c:\mongoose eaters would become c:\mongoo~1 and c:\mongoo~2). That method wouldn't deal with that prob

    Why do you want the DOS name anyway? This is the age of 255 with spaces file names!!
    Oh stop with with your logical arguments, and always making sense all the time
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7
    Jethro
    Guest
    Originally posted by chrisjk
    But what happens if you have a folder/file with almost the same name (like c:\mongoose and c:\mongoose eaters would become c:\mongoo~1 and c:\mongoo~2). That method wouldn't deal with that prob

    Why do you want the DOS name anyway? This is the age of 255 with spaces file names!!
    Persumably the guy wants to reflect how you would see a file path in DOS?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    I want the dos name because if you put something in the registry for an open command, it cant have spaces in the path and that, so if i have a program in program files, then in the reg it will put in c:\program files and when i go to run the program using the right click menu (shell) it says cant find program.exe (cause that is where the first space is.)

    Thanks

    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

  9. #9
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by crptcblade
    Oh stop with with your logical arguments, and always making sense all the time
    flob-a-lob-ba-lob.

    Hurgh, have you tried enclosing it with quotes?
    The Shell command works with spaces if you put quotes around the long-file name parts...Shell("""C:\Program Files\Mr Lover Man\Hello World.exe""") (i think that is the right no. of quotes)

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    if you want to see what i mean,
    go and look at this in regedit

    HKEY_CLASSES_ROOT\WinZip\Shell\open\command

    This is the place where winzip has it's command to open file types of *.zip and others. If you notice the open command is c:\progra~1\winzip\winzip.exe "%1" (that is assuming that you installed it in the default dir)

    If you change the progra~1 to Program Files then try and open a winzip file by dubble clicking on it, it will say something like, cant find Program.exe ........

    That is the problem that I am having.

    This is what I want to acheive.

    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

  11. #11
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I tried the Winzip example with some quotes, like so
    Code:
    "c:\program files\winzip\winzip.exe" "%1"
    and it worked fine when I d-clicked a zip file in explorer. I also tried the contect-sensitive right mouse button on other files to add to zip and that worked fine too. In conclusion, put quotes around it, it should then be fine

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    yep ta, just did that before i read your post, i had to use the chr(34) thing not like """ cause that did not work.

    Thanks everyone

    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

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