Empty Spaces In File Name

Discussion in 'Web Design, HTML And CSS' started by Carlito, Apr 30, 2009.

  1. Carlito

    Carlito New Member

    Joined:
    Apr 30, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Construction
    Location:
    Montreal
    Home Page:
    http://www.xznn.com
    Hi everyone,

    This issue is what brang me to this forum:
    Calling OFFLINE files from HTML webpage on local drive using window.setTimeOut to delay most calls. ISSUE: When I call a file w/o empty space in name, this function calls w/o error on page, but I do not know how to do it when file contains empty space(s) in its name.
    HTML:
    function runXZNNespritsPMz()
    {
    File="E:\\XZNNesprits\\ZZ XZNNesprits PMz.session";
    //can only launch such a file when no empty space present in name
    WSH=new ActiveXObject("WScript.Shell");
    WSH.run(File);
    }
    
    How do I correctly write the full path of such a file containing empty spaces in its name?

    Carl
    XZNN
     
  2. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    That problem is faced by many, I had also faced in VBScript !!

    Well, the solution is to wrap the file-name with an extra pair of quotes.
    The modified code looks like this :
    Code:
    function runXZNNespritsPMz()
    {
          FileName="\"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session\"";
          WSH=new ActiveXObject("WScript.Shell");
          WSH.run(FileName);
    }
    I think this will work, 'cuz this worked for me in VBScript :smile:
     
    Last edited: May 11, 2009
  3. Carlito

    Carlito New Member

    Joined:
    Apr 30, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Construction
    Location:
    Montreal
    Home Page:
    http://www.xznn.com

    Thanks so much SaswatPadhi. You are the first one who ever answered me a question on this forum (my first ever too!). OK I calm down.

    I tried your syntax as a var value and it is perfect in js except that there must not be present those two backslashes in between the double double quotes. So that would be:

    var whichever_name = '"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session"'

    In fact, I started to relocate many of the files and folders I needed to call through js (renaming them without any empty spaces) and found that when you look at the Properties, in WinXP, of a shortcut, it give you the target path embedded by double quotes, and, if no empty spaces in name of file nor of the whole path, it does not embed it in double quotes.

    Thanks again to reply me SaswatPadhi.
     
  4. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    The pleasure is all mine and welcome to the forum.

    Double double quotes !!!! :crazy: How does that work ? I think it's not supported. Even in VBS :
    Code:
    set WshShell = WScript.CreateObject("WScript.Shell")
    FileName = "C:\X Y Z.bat"
    WshShell.Run(chr(34)+FileName+chr(34))
    So, I thought, you have to use escape sequences in Java.

    Can someone explain this to me : how double double quotes work !?
     
  5. Carlito

    Carlito New Member

    Joined:
    Apr 30, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Construction
    Location:
    Montreal
    Home Page:
    http://www.xznn.com
    I found an error in my syntax. It really goes like this and I think it is completely legal (someone would need to confirm this though)(many people coding embedded js into HTML like to use single quotation for js related syntax and double quotation for HTML). So the correct and flawlessly performing (no errors on page within IE) syntax for my example is:

    Code:
    var whichever_name = '"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session"'
    
    By the way, what are the cool things about VBS?
     
  6. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
  7. Carlito

    Carlito New Member

    Joined:
    Apr 30, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Construction
    Location:
    Montreal
    Home Page:
    http://www.xznn.com

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice