Tuesday, July 11, 2006

 

redirection symbol in bat file

So what would happen if our MAIN.BAT had the following line in it?
echo %%"%% chkdsk | find "65535" > nul %%"%% > temp.bat
DOS would replace the first %% with a single %, then it would see the quote. Seeing the quote, it would remember to ignore all piping and redirection symbols up to the next quote. This means our quote protection ends at the quoted 65535, but it picks up again at the end of the number and continues to the last quote (far enough to protect all but the last redirection symbol which we want to act as a redirection anyway). DOS then continues to process the line, replacing the rest of the %% with %. After processing the line, it executes it, echoing our desired line
%"% chkdsk | find "65535" > nul %"%
into TEMP.BAT. All the piping and redirection is delivered intact, and we can ignore the %"%, since DOS will ignore it.


more at: eric

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?