Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
April 6, 2005
I have scripted StdErr.bat to generate output on StdErr, so that it is separate from the normal output on StdOut.
The syntax for using StdErr.bat is:
[call] StdErr Message
Where Message is a double-quoted string that you wish to display on StdErr.
If you wanted to redirect the output of a script to a file, but provide immediate display of some messages:
. . .. . .If "%AOK%" EQU "N" goto err@echo %line%>>%ReportFile%. . .goto . . .:errcall StdErr "Line %line% has an error.". . .
StdErr.bat contains:
@echo offsetlocalif exist "%TEMP%StdErr.vbs" goto out@echo dim err>"%TEMP%StdErr.vbs"@echo Set objshell = CreateObject("WScript.Shell")>>"%TEMP%StdErr.vbs"@echo Set objArgs = WScript.Arguments>>"%TEMP%StdErr.vbs"@echo err=objArgs(0)>>"%TEMP%StdErr.vbs"@echo WScript.StdErr.Writeline err>>"%TEMP%StdErr.vbs":outif {%1}=={} goto outNonecscript //nologo "%TEMP%StdErr.vbs" %1endlocalgoto :EOF:outNonecscript //nologo "%TEMP%StdErr.vbs" "No Parameter Provided."endlocal
You May Also Like