A VBS script that transfers any file to batch processing Any2bat.vbs_vbs

Source: Internet
Author: User
Tags echo b
by zzzevazzz@ph4nt0m.org

The advantage of encoding data with BASE64 is to compress the size (relative to bin2str), with the disadvantage of increasing processing time and scripting complexity.
Because the efficiency bottleneck is the step of creating a VBS in BAT, it is generally cost-effective.
Writing files with Adodb.recordset is much better than Debug.
Most of the things are scripted, and the batch process simply generates the script with Echo.
The upside of the echo version is that all copies are pasted into the cmd shell to upload the file.
Copy Code code as follows:

' Any2bat.vbs by zzzevazzz
On Error Resume Next
Set arg=wscript.arguments
If Arg.count=0 then Wscript.Quit
With CreateObject ("ADODB. Stream ")
. Type=1:.open:.loadfromfile Arg (0): Bs=.read:l=.size:.close
End With
If Err.number<>0 then Wscript.Quit
Set Fso=createobject ("Scripting.FileSystemObject")
With Fso.opentextfile (ARG (0) & ". bat", 2,true)
If Err.number<>0 then Wscript.Quit
. WriteLine "@echo Bs=_>xx.vbs"
For K=1 to L step 129
. Write "@echo" ""
. Write b64b (MidB (bs,k,129))
. WriteLine "" "+_>>xx.vbs"
Next
. WriteLine "@echo" "": Set Rs=createobject ("" ADODB. Recordset "") >>xx.vbs "
. WriteLine "@echo Set Ado=createobject (" "ADODB. Stream "") >>xx.vbs "
. WriteLine "@echo L=len (BS): ss=" "": for K=1 to L step 4096:ss=ss+ub64 (Mid (bs,k,4096)): Next:l=len (ss) >>xx.vbs "
. WriteLine "@echo rs.fields.append" "B" ", 205,l/2:rs.open:rs.addnew:rs (" "B" ") =SS+CHRB (0): Rs.update>>xx.vbs"
. WriteLine "@echo Ado.mode=3:ado.type=1:ado.open:ado.write rs (" "" B "). GetChunk (L/2) >>xx.vbs"
. WriteLine "@echo Ado.savetofile" "+fso.getfilename (ARG (0)) +" ", 2:ado.close>>xx.vbs"
. WriteLine "@echo function ub64 (s):d im T (4), B (3): ub64=" "": N=len (s): r=2 >>xx.vbs "
. WriteLine "@echo If n mod 4^<^>0 then exit Function:end if:for i=1 to n step 4:for j=0 to 3 >>xx.vbs"
. WriteLine "@echo A=asc (mid s,i+j,1): If a=43 then:a=62:else if a=47 then:a=63:else if a^>47 and a^<58 Then:_>&gt ; Xx.vbs "
. WriteLine "@echo A=a+4:else if a=61 then:a=0:if r=2 then r=j-2:end if:else if a^>64 and a^<91 then:_>>xx.vbs"
. WriteLine "@echo A=a-65:else if a^>96 and a^<123 then:a=a-71:else:exit function:_>>xx.vbs"
. WriteLine "@echo End if:end if:end if:end if:end if:end if:t (j) =a:next>>xx.vbs"
. WriteLine "@echo B (0) =t (0) +t (1) *64 mod 256:b (1) =t (1) \4+t (2) *16 mod 256:b (2) =t (2) \16+t (3) *4 >>xx.vbs"
. WriteLine "@echo for J=0 to R:if B (j) ^<16 then ub64=ub64+" "0" "": End If:ub64=ub64+hex (b (j)) >>xx.vbs "
. WriteLine "@echo next:next:end function>>xx.vbs&&cscript.exe//nologo xx.vbs&del xx.vbs"
End With
Const B64 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"
function b64b (BIN)
B64b= ""
N=lenb (BIN)
For I=1 to n step 3
A=ASCB (MidB (bin,i,1))
B64b=b64b+mid (b64,a mod 64+1,1)
If I<n Then
B=ASCB (MidB (bin,i+1,1))
B64b=b64b+mid (b64, (a\64+b*4) mod 64+1,1)
If I+1<n Then
C=ASCB (MidB (bin,i+2,1))
B64b=b64b+mid (b64, (b\16+c*16) mod 64+1,1)
B64b=b64b+mid (b64,c\4+1,1)
Else
B64b=b64b+mid (b64,b\16+1,1)
b64b=b64b+ "="
End If
Else
B64b=b64b+mid (b64,a\64+1,1)
b64b=b64b+ "= ="
End If
Next
End Function


The usage is simple, just one argument-the full path of the file to be converted.
You can also drag and drop the file directly onto the icon for this VBS.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.