How do I wrap a path with spaces in double quotes? [solved]

Get help using Construct 2

Post » Wed Jan 11, 2017 9:20 pm

In the NWjs plugin, the action "File System > Run file" says:

To execute a path with spaces in it, wrap in double-quotes (e.g. """C:\Program Files\file.exe""").


How can this be done?

I've tried using many combinations of quote marks, as variables or directly using (&" ' ' ' ' ") in multiple combinations.

Any concrete examples?

Thx
Last edited by hmott on Thu Jan 12, 2017 4:06 pm, edited 1 time in total.
B
17
S
2
Posts: 88
Reputation: 1,503

Post » Wed Jan 11, 2017 11:33 pm

Run
Code: Select all
"""C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe"""

works for me..

...also in variable
Image
Image
B
65
S
23
G
7
Posts: 1,504
Reputation: 10,894

Post » Thu Jan 12, 2017 3:20 pm

Thanks @korbaach,

I forgot to mention that I'm looking to apply this method to open a folder, not run an executable.

Using the variable method and a text box in the app as the input, I can run an executable with quotes:

"c:\Program Files\program.exe"

Using the same input box, I've added the word "start" in front of the folder I want to open. But this only works with folder paths without spaces, like "c:\". Once I add spaces, I haven't yet found a way to make it work.
B
17
S
2
Posts: 88
Reputation: 1,503

Post » Thu Jan 12, 2017 4:05 pm

I've found something from this link

http://stackoverflow.com/questions/1880 ... in-windows

A workaround I use is to use the "short names" for the directories in the path, instead of their standard, human-readable versions. So e.g. for C:\Program Files\ I would use C:\PROGRA~1\ You can find the short name equivalents using dir /x.


The basics is the first six characters in uppercase, followed by a tilde, then a number to differentiate multiple folders with the same first six characters.

"C:\PROGRA" + "~" + "1"

This numeric approach will eventually break if you have multiple folders with the same first six characters. But windows uses this short-form convention on all folders and starts getting creative with it. You'll have to find exactly which short form windows has assigned the folder you want. To find it, press and hold the windows key, then press "R", which will bring up the "Run" window. Type "cmd" to bring up a dos command window from the 1890's (or 80's?).

Navigate to the folder that has within it the folders you want to see the short forms for. Then type "dir /x". A table of the folders in the current directory will appear along with their short forms.

Then replace the folder path component with spaces in it with this short form.

Then you can set a variable in c2 to "start c:\PROGRA~1\SUBFOL~1\..." without any quotes. Once this runs, windows will then recognize the short forms and open you folder.

Easy, right? :D
B
17
S
2
Posts: 88
Reputation: 1,503

Post » Thu Jan 12, 2017 4:15 pm

I've added the word "start" in front of the folder I want to open

or you can just replace word "start" with "explorer "

Code: Select all
"explorer ""C:\Program Files"""

Code: Select all
"explorer ""C:\Program Files\Microsoft SQL Server"""


Image
Image
B
65
S
23
G
7
Posts: 1,504
Reputation: 10,894

Post » Thu Jan 12, 2017 6:43 pm

korbaach wrote:
I've added the word "start" in front of the folder I want to open

or you can just replace word "start" with "explorer "

Code: Select all
"explorer ""C:\Program Files"""

Code: Select all
"explorer ""C:\Program Files\Microsoft SQL Server"""


Image


Yes, or that.
B
17
S
2
Posts: 88
Reputation: 1,503

Post » Tue Feb 07, 2017 7:12 pm

korbaach wrote:
I've added the word "start" in front of the folder I want to open

or you can just replace word "start" with "explorer "

Code: Select all
"explorer ""C:\Program Files"""

Code: Select all
"explorer ""C:\Program Files\Microsoft SQL Server"""


Image


In the desktop program I've created, I put in a "paste" button that copies the clipboard content and sends it to a text object for the user to see. It then also checks if the folder exists, and if it does, it displays a list of its subfolders.

I've run into the problem of special characters in the file path. When there are periods in the filepath, checking for the existence of the filepath causes an error. When there is an ampersands (&) in the filepath, checking for the folder works, but using the "open folder" command opens an explorer window, but not the filepath obtained from the clipboard.

Pasting the file path directly into an explorer window always seems to work if the folder exists. Any ideas on how to handle special characters in the filepath in the nwjs plugin to prevent errors?
B
17
S
2
Posts: 88
Reputation: 1,503


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu and 6 guests