redirect.vbs (886B)
1 Option Explicit 2 3 Dim WshShell 4 Dim fso 5 Dim exe, src, dest 6 7 Set WshShell = Wscript.CreateObject("Wscript.Shell") 8 Set fso = WScript.CreateObject("Scripting.FileSystemObject") 9 10 If Not(Wscript.Arguments.Count = 3) Then 11 Wscript.Echo "Usage: redirect.vbs <.exe file> <source file> <text file>" 12 WScript.Quit 1 13 End If 14 15 exe = WScript.Arguments(0) 16 src = WScript.Arguments(1) 17 dest = WScript.Arguments(2) 18 If Not(fso.FileExists(exe)) Then 19 WScript.Echo "Executable not found: " & exe 20 WScript.Quit 1 21 End If 22 23 If Not(fso.FileExists(src)) Then 24 WScript.Echo "Source file not found: " & src 25 WScript.Quit 1 26 End If 27 28 If Not(fso.FolderExists(Left(dest, InstrRev(dest, "\")))) Then 29 WScript.Echo "Destination folder not found: " & Left(dest, InstrRev(dest, "\")) 30 WScript.Quit 1 31 End If 32 33 WshShell.Run "%comspec% /c " & exe & " " & chr(34) & src & chr(34) & " > " & chr(34) & dest & chr(34), 0, true