Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to redirect run output to file

1,538 views
Skip to first unread message

moonhkt

unread,
Mar 31, 2011, 12:42:36 PM3/31/11
to
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

unread,
Mar 31, 2011, 2:32:51 PM3/31/11
to
On Mar 31, 10:42 am, moonhkt <moon...@gmail.com> wrote:

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

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

unread,
Mar 31, 2011, 9:00:45 PM3/31/11
to

Hi,
thank, But how to redirection by vbs ?

moonhkt

Dave "Crash" Dummy

unread,
Apr 1, 2011, 7:15:35 AM4/1/11
to

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)

"dir" is an operation of the cmd.exe shell, not an executable program.
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

"It is not necessary to change. Survival is not mandatory."
~ W. Edwards Deming ~

Mayayana

unread,
Apr 1, 2011, 9:37:25 AM4/1/11
to
Since you're asking in a VBS group:

Did you know that you can use the FileSystemObject
to write a list of files to disk? It's not as terse as
DOS/batch, but it's 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

unread,
Apr 1, 2011, 8:44:38 AM4/1/11
to

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 don't take real
well to VBS related subjects ;^).
(let the flames begin)
_____________________
Tom Lavedas

moonhkt

unread,
Apr 1, 2011, 11:16:40 AM4/1/11
to

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

0 new messages