Why doesn't redirect work?

October 3, 2009 at 20:46:35
Specs: Windows XP Pro, Core 2 / 2MB
I was pretty good in DOS, but I'm lost in XP.

This works fine:
@ echo Press the Y key and then press Enter
@del "C:\Documents and Settings\All Users\Application Data\avg8\Log\*.*">nul

This does not:
@del "C:\Documents and Settings\All Users\Application Data\avg8\Log\*.*"<c:\y.txt
Where Y.txt contains Y

The Y is redirected to the del command, but files are not deleted.


See More: Why doesnt redirect work?

Report •

October 4, 2009 at 00:16:12

@echo y | del "C:\Documents and Settings\All Users\Application Data\avg8\Log\*.*"

Report •

October 4, 2009 at 02:13:52
Thanks a lot; it worked.

I haven't done this in so long I've forgotten the basics.

Report •

October 4, 2009 at 05:57:30

You're quite right that XP is different from DOS in many important ways.

For both DOS & XP [NT5x], some commands will take a pipe or redirect and some won't.

In the case of DEL, NT has a built-in switch:

/Q Quiet mode, do not ask if ok to delete on global wildcard

[del /?]

Helping others achieve escape felicity


Report •

Related Solutions

October 23, 2009 at 09:28:23
Yeah, reverse redirection does not always work, even on standard commands. Do check that you input command contains an enter (after the text you want to give it), this may be a reason why it fails as well.

Report •

October 23, 2009 at 14:47:28
Back to the original question,
The Y is redirected to the del command, but files are not deleted.

Presumably, your 'y.txt' has just a "Y", and no trailing Enter.

Report •

Ask Question