C++/VB - How to redirect run output to file

Asked By moonhkt on 31-Mar-11 12:42 PM
Hi All

How to redirect output to file ?  and how to disable prompt DOS
prompt ?

vb script run by cscript


Dim objshell
Dim ireturn
Dim textfile

Set objshell = CreateObject("Wscript.Shell")

ireturn = objshell.Run( "dir c:\ > c:\temp\abc.txt" ,, False)
ireturn = objshell.Run( "dir d:\ >> c:\temp\abc.txt" ,, False)

moonhkt


Bill Stewart replied to moonhkt on 31-Mar-11 02:32 PM
Hi,

Command line redirection is performed by the command line interpreter:
http://blogs.msdn.com/b/oldnewthing/archive/2006/05/16/598893.aspx

--
Bill Stewart
moonhkt replied to Bill Stewart on 31-Mar-11 09:00 PM
p://blogs.msdn.com/b/oldnewthing/archive/2006/05/16/598893.aspx

Hi,
thank, But how to redirection by vbs ?

moonhkt
Dave \Crash\ Dummy replied to moonhkt on 01-Apr-11 07:15 AM
ireturn = objshell.Run( "cmd /c dir c:\ > c:\temp\abc.txt" ,0, True)
ireturn = objshell.Run( "cmd /c dir d:\ >> c:\temp\abc.txt" ,0, False)

The first instance must wait until it is complete or the second instance
will overwrite the text file instead of amending it. The Window Style
must be specifically set to "hidden" (0), or a command box will pop up
momentarily.
--
Crash

~ W. Edwards Deming ~
Mayayana replied to moonhkt on 01-Apr-11 09:37 AM
Since you are asking in a VBS group:

Did you know that you can use the FileSystemObject
to write a list of files to disk? it is not as terse as
DOS/batch, but it is more flexible.

If you actually prefer to work in "neo-DOS" there are
two groups that might be useful:

alt.msdos.batch.nt
microsoft.public.win2000.cmdprompt.admin
Tom Lavedas replied to Mayayana on 01-Apr-11 08:44 AM
The first group suggested above is far more active than the second.
However, IMHO running command console statements from within VBS is
probably handled here slightly better than there.  The batch denizens
tend to be a bit parochial about 'their' group and do not take real
well to VBS related subjects ;^).
(let the flames begin)
_____________________
Tom Lavedas
moonhkt replied to Tom Lavedas on 01-Apr-11 11:16 AM
On 4=E6=9C=881=E6=97=A5, =E4=B8=8B=E5=8D=888=E6=99=8244=E5=88=86, Tom Laved=
s

Thank a lot.
Using FileSystemObject is reading the file for other process.