Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use vbs to convert a file into a vbs statement

Shulou Source: shulou.com Published: 2022-06-03 07:15:01 09月16日 Update

This article mainly introduces how to use vbs to convert files into vbs statements, the article is very detailed, has a certain reference value, interested friends must read it!

This is not all types of exe2vbs files can be converted, but limited to the size of string files can not be too large, I have tested 3m files is OK.

Save the following code as: file2vbs.vbs

The copy code is as follows:

'Program By xiaolu

'name:file2vbs.vbs

On error resume next

Do while 1

Fname=InputBox ("Please enter the file name (including path) to be converted:", "enter the file name", "f:\ hhh.exe")

If fname= "" then Wscript.quit

Err.number=0

Set Ado = createObject ("adodb.stream")

With Ado

.Type = 1

.open

.loadfromfile fname

Ss = .read

End With

If err.number0 then

If msgbox ("File opening error!", 1, "File2VBS") = 2 then Wscript.quit

Else

Exit do

End if

Loop

Fname=InputBox ("Please enter the vbs name (including the path):", "enter the file name", "f:\ hhh.vbs")

If fname= "" then Wscript.quit

Set Fso=createObject ("Scripting.FileSystemObject")

Set File=fso.OpenTextFile (fname,2, True)

Lens=lenB (ss) mod 500

For juni0 to int (lenB (ss) / 500)-1

If jung0 then

File.writeline "ss="& Bin2Str (midb (ss,500*j+1500)) &"_"

Else

File.writeline "+" & Bin2Str (midb (ss,500*j+1500)) & "" _ "

End if

Next

If lens > 0 then

File.writeline "+" & Bin2Str (rightb (ss,lens)) & "

Else

File.writeline "+" & chr (34) & chr (34)

End if

File.writeline ""

File.writeline "Set RS=createObject ("ADODB.Recordset"): L=Len (ss) / 2:RS.Fields.Append "" m ", 205GetChunk (L)"

File.writeline "Set s=createObject (" ADODB.Stream "): with s:.Mode = 3:.Type = 1:.Open (): .Write ss:.SaveToFile wscript.arguments (0), 2:end with"

File.close

Set fso=nothing

Ado.close

Set Abo=nothing

Function Bin2Str (Re)

For I = 1 To lenB (Re)

Bt = AscB (MidB (Re, I, 1))

If bt < 16 Then Bin2Str=Bin2Str& "0"

Bin2Str=Bin2Str & Hex (bt)

Next

End Function

The method of generating files

Cscript file2vbs.vbs c:\ test.exe

The above is all the contents of the article "how to use vbs to convert files into vbs statements". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: File input code file name statement content article path value interest method size partner more knowledge type industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei Docker Apple MariaDB