On Error Resume Next sHeader = "spreadclient 1.0-vbs" & vbCrLf & _ "(c) 2007-2008 by Marc Ruef" & vbCrLf & _ "http://www.computec.ch/projekte/spread/" & vbCrLf Set oArgs = WScript.Arguments sInputFileName = oArgs(0) sOutputFileName = oArgs(1) Wscript.Echo sHeader If (WScript.Arguments.Count() <> 2) Then Wscript.Echo "Arguments missing." & vbCrLf & vbCrLf & _ "Syntax" & vbTab & vbTab & "spreadclient.vbs " & vbCrLf & _ "Example" & vbTab & vbTab & "spreadclient.vbs D:\tmp\input.spr C:\cmd.exe" & vbCrLf If(LenB(sInputFileName) = 0) Then sInputFileName = InputBox("Please enter the path and file name of the source spreadcode file:", "Source File", "C:\input.spr") End If If(LenB(sOutputFileName) = 0) Then sOutputFileName = InputBox("Please enter the path and file name of the destination file:", "Destination File", "C:\output.tmp") End If End If Call WriteStatus("Open input file ...", 0) Set oFSO = CreateObject("Scripting.FileSystemObject") Set oTest = oFSO.GetFile(sInputFileName) If oTest.Size = 0 Then Call WriteStatus("Source file not found.", 1) ElseIf (LenB(sOutputFileName) = 0) Then Call WriteStatus("Destination file not specified.", 1) Else Call WriteStatus("Read input file ...", 0) Set oFileSource = oFSO.OpenTextFile(sInputFileName, 1) sContentSource = oFileSource.ReadAll oFileSource.Close If (InStr(1, sContentSource, " ", vbBinaryCompare)) Then Call WriteStatus("Normalizing input file ...", 0) sContentSource = Replace(sContentSource, " ", "", 1, -1, vbBinaryCompare) End If Call WriteStatus("Computing length of input file ...", 0) lContentLength = Len(sContentSource) Call WriteStatus("Creating output file ...", 0) Set oFileDestination = CreateObject("Scripting.FileSystemObject").OpenTextFile(sOutputFileName, 2, True) Call WriteStatus("Writing output file ...", 0) For i = 1 To lContentLength Step 2 oFileDestination.Write Chr(Clng("&H" & Mid(sContentSource, i, 2))) Next oFileDestination.Close Call WriteStatus("Testing output file ...", 0) Set oFileDestination = oFSO.GetFile(sOutputFileName) If oFileDestination.Size = 0 Then Call WriteStatus("Writing output file failed.", 1) Else Call WriteStatus("File spread.", 0) Wscript.Echo vbCrLf & _ "Source" & vbCrLf & _ vbTab & "Name" & vbTab & sInputFileName & vbCrLf & _ vbTab & "Size" & vbTab & lContentLength & " bytes" & vbCrLf & vbCrLf & _ "Destination" & vbCrLf & _ vbTab & "Name" & vbTab & sOutputFileName & vbCrLf & _ vbTab & "Size" & vbTab & oFileDestination.Size & " bytes" End If End If Private Sub WriteStatus(ByRef sStatusMessage, ByRef iShowAlways) If (IsCscript) Then Wscript.Echo Date & " " & Time & vbTab & sStatusMessage ElseIf (iShowAlways) Then Wscript.Echo sStatusMessage End If End Sub Private Function IsCscript() If (InStr(wscript.FullName, "cscript")) Then IsCscript = 1 Else IsCscript = 0 End If End Function