sort <foo.txt >bar.txt works when I type it at a DOS prompt, but fails
in a script. Anyone got an idea how I can do this?
Marianne
Marianne Anderson <marianne...@digital.com> wrote in message news:37D7CED1...@digital.com...
Michael Harris <Please...@To.Group> wrote in message news:umTeleu##GA....@cppssbbsa02.microsoft.com...
I didn't really see a good explanation of this in the documentation I
have. This was
exactly what I needed to make sense of things.
Marianne
Michael Harris wrote:
> This is such a common question/problem, an explanation is probably in
> order. You have to think of Windows as having two "command line"
> environments:
>
> * the standard console window (aka, DOS box).
> * the other represented visually by the Windows Run dialog box.
> The WScript.Shell's Run method is (logically speaking) the
> non-visual counterpart of the Windows Run dialog.
>
> A command like "sort <c:\foo.txt >c:\bar.txt" won't work from either
> variation of the "Windows command line" because the "Windows command
> line" doesn't support redirection. Only the "console window" command
> line supports redirection. To illustrate, create c:\foo.txt (with
> several unsorted arbitrary lines) and try entering the following
> command in the Windows Run dialog: sort <c:\foo.txt >c:\bar.txt The
> console window flashes by, but no c:\bar.txt file is created. Now
> try: %comspec% /c sort <c:\foo.txt >c:\bar.txt Again, the console
> window flashes by, but this time c:\bar.txt file _is_ created.
> --
> Michael Harris
>
> Michael Harris <Please...@To.Group> wrote in message
> news:umTeleu##GA....@cppssbbsa02.microsoft.com...Shell.Run
> "%comspec% /c sort <foo.txt >bar.txt",0,true
> --
> Michael Harris
>
> Marianne Anderson <marianne...@digital.com>
> wrote in message
> news:37D7CED1...@digital.com...I'd like to