Computer Science Canada

Sys.Exec with spaces

Author:  gitoxa [ Thu Apr 17, 2008 8:49 pm ]
Post subject:  Sys.Exec with spaces

I'm trying to open up some files using the Sys.Exec command. Problem is, it can't find the file I'm trying to open. I realized that even though the variable with the filename in it had all the info, the Sys.Exec command only took up to the first space. I tested other files in the folder, without spaces, and they worked fine.

Any ideas how to get around this?

Author:  Dan [ Thu Apr 17, 2008 9:05 pm ]
Post subject:  RE:Sys.Exec with spaces

yes, you have to put files with spaces in ""s in the string.

So if i wanted to open somthing in notepad with a space in the name i would need to do somthing like this:

Sys.Exec("notepad.exe \"my text file.txt\"")

Assuming notepad.exe is in the systems path and my text file.txt is in the working dir.

Author:  gitoxa [ Thu Apr 17, 2008 9:13 pm ]
Post subject:  RE:Sys.Exec with spaces

The problem was I had it in a variable, and throwing quotations around one didn't seem like the best thing to do.

I got it though

code:
File := "\"" + File + "\""

Did that before putting it into Sys.Exec

Thanks.


: