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
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:
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.
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 !?
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?
If you want a comparison between VBS and JS, go here : http://msdn.microsoft.com/en-us/library/ms974627(loband).aspx. :smile: