ExecFile problems

Blitz3D Forums/Blitz3D Beginners Area/ExecFile problems

PowerPC603(Posted 2006) [#1]
Hi all,

I tried to list all running tasks to a textfile.
I'm using WinXp Pro and opened the command prompt (Start menu -> Execute -> cmd)
I tried "tasklist > c:\tasks.txt", which works from there, but if I use this exact line within ExecFile like this:
ExecFile("tasklist > c:\tasks.txt")
the file c:\tasks.txt isn't there.

When I create a .bat file ("c:\CreateTaskList.bat"), which holds the line:
tasklist > c:\tasks.txt
and I do:
ExecFile("c:\CreateTaskList.bat")
it works.

But I wanna do it directly from within Blitz, how can I do it?
I tried setting the command in a variable (string), but that doesn't work also.

a$ = "tasklist > c:\tasks.txt"
ExecFile(a$)

Doesn't work either.

Not even this:

a$ = Chr$(34) + "tasklist > c:\tasks.txt" + Chr$(34)
ExecFile(a$)

Can someone help me with this?
If I try the example from the Blitz docs:
ExecFile("calc.exe")
That works.
Strange.
It seems that it doesn't work when the called command must write something to a file.


GfK(Posted 2006) [#2]
Dunno... try ExecFile("tasklist > "+Chr$(34)+"c:\tasks.txt"+Chr$(34))


PowerPC603(Posted 2006) [#3]
Nope, still no luck.
Just tried 5 times.


PowerPC603(Posted 2006) [#4]
I found it (finally):
ExecFile("cmd /C " + Chr$(34) + "tasklist > c:\tasks.txt" + Chr$(34))

What a workaround :)