Hi All
Can i read Dos command out values in file or Buffer?
For example if i run dir command in dos then it show file and directory name.Now i want to store these file and directory in file or Buffer.
is it possible then guide me..
Printable View
Hi All
Can i read Dos command out values in file or Buffer?
For example if i run dir command in dos then it show file and directory name.Now i want to store these file and directory in file or Buffer.
is it possible then guide me..
1. I gave some links that could help in your previous thread about running .bat (.cmd) files.
2. To get the result of "dir command" you don't need starting ms dos dir. There are Windows APIs (FindFirstFile/FindNextFile/FindClose) and their MFC wrapper (CFileFind class) that you should use.
Thanks for reply
Yes your link help me to solve last problem.
sir dir command just a example, command may be Copy con,Makedir etc
Sir is it possible to read values from command prompt?
Please guide me
MS Dos copy and mkdir have corresponding Win32 "analogs": CopyFile and CreateDirectory. :cool:
What will you read by dos command copy or delete ?
No, Msm posted Can i read Dos command out values in file or Buffer?
So what will he store in file or buffer by copy or delete command ?.
Oh yes I didn't check that he asked for values to be read from console. I though he asked for output screen to be saved in file stream.
You can of course redirect the output of any console command to a file which can then be read. However, I'm unclear as to why one would do such a thing. Perhaps if you clarified your high-level objective rather than focusing on your present strategy?
Strangely enough I needed to do this today! I was running a DOS applicartion that was printing some error message in its console and then immediately aborting (taking the console down with it). Let's say your DOS app is called "app" and you want to see its output in a file called "file.txt". Just run the application from a command prompt by typing app > file.txt You'll then be able to open file.txt in any text editor and view the output. There's probably a way to do this programmatically too but I don't know what it is.
The '>' symbol BTW is called a pipe if I remember correctly.
I always thought that pipe is '|'. :rolleyes:
And passing "app > file.txt" in the CreateProcess won't work.
See http://www.codeguru.com/forum/showpo...5&postcount=10
This would accomplish the goal, you could then use the text file to parse the results. Maybe not the best way though.Code:system("dir >> myfile.txt");