REM This file compiles Tee.vb to Tee.exe
REM Tee.exe Reads from StdIn and writes to StdOut and a file.
REM To use
REM Tee Filename
Rem Filename - name of file
Rem
Rem Example
Rem
Rem tee "%userprofile%\Desktop\winini.txt" < "%windir%\win.ini"
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\Tee.exe" "%~dp0\Tee.vb"
pause
-------------------------------------------------------------------------------------
'Tee.vb
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Module Tee
Sub Main
Dim Line as Object
Dim FSO as Object
Dim File as Object
On Error Resume Next
Fso = CreateObject("Scripting.FileSystemObject")
File = Fso.CreateTextFile(Replace(Command(), """", ""), True)
If err.number <> 0 then
Console.WriteLine("Error: " & err.number & " " & err.description & " from " & err.source)
err.clear
Else
Line=Console.readline
Do Until Line = vbnull
File.Writeline(Line)
Console.WriteLine(Line)
Line = Console.ReadLine
Loop
End If
End Sub
End Module
No comments:
Post a Comment