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
> 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
Hi,
thank, But how to redirection by vbs ?
moonhkt
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 ~
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
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
Thank a lot.
Using FileSystemObject is reading the file for other process.