Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off & CD "%~dp0"
- If "!" == "" (
- Echo(Delayed Expansion not permitted prior to definition of TEE macro
- Pause
- Exit /B 1
- )
- (Set \n=^^^
- %= \n Macro newline Variable. Do not modify =%)
- Set TEE=For %%n in (1 2)Do if %%n==2 (%\n%
- ^>^>"File" Echo(------------------------------------------------------------------%\n%
- ^>^>"File" Echo( !Date! @ !TIME!%\n%
- ^>^>"File" Echo( !CMDArg!%\n%
- ^>^>"File" Echo(------------------------------------------------------------------%\n%
- For /F "Delims=" %%G in ('@^(!CMDArg!^^)')Do (%\n%
- Echo(%%G%\n%
- ^>^>"File" (Echo(%%G)%\n%
- )%\n%
- ^>^>"File" Echo(%\n%
- )Else Set CMDArg=
- Setlocal EnableExtensions EnableDelayedExpansion
- :# Output filename.ext supplied during expansion of TEE macro using Substring modification
- :# For multiline commands, the linefeed should be escaped
- :# - The leading character of line following escaped linefeed is consumed by the escape.
- :# Echo statements preceeding escaped linefeeds should be parenthesised to ensure no unintended whitespace is output
- :# Command tokens < > & | require escaping
- :# Examples of using TEE with different command types:
- Set "input="
- Set /P "input=Enter Input: "
- If defined input (
- %TEE:File=Outfile.dat% Echo(%input%
- )Else %TEE:File=Outfile.dat% Set TEE
- %TEE:File=Outfile.dat% For /L %%i in (1 1 3)Do (^
- (Echo(Square %%i)^
- ^& (Echo(%%i*%%i)^
- )
- %TEE:File=Outfile.dat% ^<nul Set /P "=Hello world"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement