1.

Solve : open a file?

Answer»

Hi all!

Please help me out.

I'm trying to open temp.txt file, but the problem is space between Program Files

FOR /F %%s in ("C:\Program Files\temp.txt") do echo %%s

Any sugestion?
THANK You.
Code: [Select]FOR /F %%s in ("C:\Progra~1\temp.txt") do echo %%s

8-)Thanks!

Is this the only way?Quote

Is this the only way?

Of course not, there are always alternative ways to do anything on a PC.

Consider:

Code: [Select]Const ForReading = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\program files\temp.txt",ForReading)
R = f.ReadAll
WScript.Echo r
f.close

After saving the script with a vbs extension, run as cscript scriptname.vbs Is ONE better than the other? That's your choice. 8-)There are many ways. Here are a couple more using almost your exact code:

Code: [Select]FOR /F "delims=" %%s in ("C:\Program Files\temp.txt") do echo %%s
Code: [Select]FOR /F "tokens=*" %%s in ("C:\Program Files\temp.txt") do echo %%s


Discussion

No Comment Found