catch CONOUT$ in For / F ?
Moderator: DosItHelp
catch CONOUT$ in For / F ?
Please, If I execute a command that write to CONOUT$ file the contents is printed in screen, but there a way of catch this in for /f ?
Re: catch CONOUT$ in For / F ?
I tried for example using makecab use as inf file the CONOUT$
I redirect to NUL but it anyways print.
code based in my getDate function: http://www.dostips.com/forum/viewtopic.php?p=29758#p29758
I need redirect CONOUT$ to CON for catch the content with For /F
I redirect to NUL but it anyways print.
code based in my getDate function: http://www.dostips.com/forum/viewtopic.php?p=29758#p29758
I need redirect CONOUT$ to CON for catch the content with For /F
Code: Select all
@Echo Off
Call :Init
Call :Test
Goto :Eof
:Init
(
Echo .Set InfHeader=""
Echo .Set InfSectionOrder=""
Echo .Set InfFooter="%%2"
Echo .Set InfFooter1=""
Echo .Set InfFooter2=""
Echo .Set InfFooter3=""
Echo .Set InfFooter4=""
Echo .Set Cabinet="OFF"
Echo .Set Compress="OFF"
Echo .Set DoNotCopyFiles="ON"
Echo .Set RptFileName="NUL"
Echo .Set InfFileName="CONOUT$"
) >"%Temp%\~foo.ddf"
Goto :Eof
:Test
Makecab /F "%Temp%\~foo.ddf" >NUL
Pause
Re: catch CONOUT$ in For / F ?
CON is the name of the console driver. I tested redirecting to CONOUT and it works OK. However, redirecting to CONOUT$ redirects to the console again. I can only suppose that the $ at end is a marker for device driver names (I think I read something about this point long time ago). If this is true, then there is no way to use CONOUT$ as a file name...
Antonio

Antonio
Re: catch CONOUT$ in For / F ?
I don't see the context to a FOR /F
You could use the behaviour of Windows that doesn't allow trailing spaces in a file name but outomatically removes them instead.
It's only a workaround but it doesn't explain why CONOUT works while CONOUT$ does not. Currently I have no idea ...
Regards
aGerman

You could use the behaviour of Windows that doesn't allow trailing spaces in a file name but outomatically removes them instead.
Code: Select all
>CONOUT$^ echo Hello world!
It's only a workaround but it doesn't explain why CONOUT works while CONOUT$ does not. Currently I have no idea ...
Regards
aGerman
Re: catch CONOUT$ in For / F ?
How could I miss that. I use CreateFile for a long time but was never aware of these stream keywords.