Option Explicit Dim i, intByte Dim objBinFile, objBinStream, objFSO, objScript Dim strBinFile, strFileExt, strFileName, strLine, strOut, strScriptVer strScriptVer = "1.00" Const ForAppending = 8 Const ForReading = 1 Const ForWriting = 2 Const TristateFalse = 0 Const TristateMixed = -2 Const TristateTrue = -1 Const TristateUseDefault = -2 Set objFSO = CreateObject( "Scripting.FileSystemObject" ) With WScript.Arguments If .Named.Count > 0 Then Syntax If .Unnamed.Count = 1 Then strBinFile = .Unnamed(0) If Not objFSO.FileExists( strBinFile ) Then Syntax Else Syntax End If End With Set objBinFile = objFSO.GetFile( strBinFile ) Set objBinStream = objBinFile.OpenAsTextStream( ForReading, TristateFalse ) strFileName = objFSO.GetBaseName( strBinFile ) strFileExt = objFSO.GetExtensionName( strBinFile ) i = 0 strOut = "Option Explicit" & vbCrLf _ & "Dim objFile, objFSO" & vbCrLf _ & "Const ForWriting = 2" & vbCrLf _ & "Set objFSO = CreateObject( ""Scripting.FileSystemObject"" )" & vbCrLf _ & "Set objFile = objFSO.CreateTextFile( """ & strFileName & "." & strFileExt & """, False, False )" & vbCrLf Do While Not objBinStream.AtEndOfStream i = i + 1 If i = 10 Then i = 0 strOut = strOut & "objFile.Write" & Mid( strLine, 3 ) & vbCrLf strLine = "" End If intByte = Asc( objBinStream.Read(1) ) strLine = strLine & " & Chr(" & intByte & ")" Loop objBinStream.Close Set objBinStream = Nothing Set objBinFile = Nothing If strLine <> "" Then strOut = strOut & "objFile.Write" & Mid( strLine, 3 ) & vbCrLf strOut = strOut _ & "objFile.Close" & vbCrLf _ & "Set objFile = Nothing" & vbCrLf _ & "Set objFSO = Nothing" & vbCrLf _ & "WScript.Echo ""Created """"" & strFileName & "." & strFileExt & """""""" & vbCrLf Set objScript = objFSO.CreateTextFile( strFileName & ".vbs", False, False ) objScript.Write strOut objScript.Close Set objScript = Nothing Set objFSO = Nothing Sub Syntax( ) ' Display help and, optionally, debugging information WScript.Echo "Bin2Vbs.vbs, Version " & strScriptVer & vbCrLf _ & "Convert a (small) binary file to a script that can recreate that file" _ & vbCrLf & vbCrLf _ & "Usage: BIN2VBS.VBS binfile" _ & vbCrLf & vbCrLf _ & "Where: ""binfile"" is the fully qualified path of the binary file" _ & vbCrLf & vbCrLf _ & "Result: The VBScript file will be created in the current directory," _ & vbCrLf _ & " with the NAME of the binary file, and extension "".VBS""" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Quit 1 End Sub