CODE: [Copy to clipboard]
:: Code by-q8249014 CMD@XP Exe2Bat.cmd
:: update 2010-1-8
@echo off&endlocal&setlocal enabledelayedexpansion
set /a "count=0,str=240,var=%random%%%10"
set "hx=0123456789ABCDEF"
set /p file=请输入文件的绝对路径 [建议直接将文件拖放到此窗口中,最大 65280 字节]:&cls
for /f "eol=? delims=" %%i in ("!file!") do (if not exist "%%~$:i.\*" (
set "expname=%%~xi"&set /a "size=%%~zi-1"))
if not defined size echo.输入错误?&%0
if %size% NEQ -1 (if 65279 LSS %size% echo.文件太大了!&%0) else (echo.0 字节?&%0)
2>nul del /a /q /f cmp_.ps
>nul fsutil file createnew "%~dp0cmp_.ps" %size%
>>"%~dp0cmp_.ps" <nul set/p"=%var%"
(echo.@echo off
echo.^>nul ^(chcp 437^&graftabl 936^)
echo.more +6 %%0^|debug
echo.2^>nul del /a /q /f new_%expname%^&ren tmp_ new_%expname%
echo.pause
echo.exit/b)>"%~dp0test_.bat"
set "file=!file:"=!"
echo.正在对文件进行编码,请稍后…………&echo.
(for /f "skip=1 tokens=1,3 delims=: " %%i in ('fc /b "%~dp0cmp_.ps" "!file!"') do (
set /a "offset=0x%%i,newline=count&15"
if !newline! EQU 0 call :Dxh
if !offset! EQU !count! (<nul set /p"= %%j") else (
set /a addzero=offset-count
for /l %%i in (1 1 !addzero!) do (
<nul set /p"= 00"
set /a "count+=1,newline=count&15"
if !newline! EQU 0 call :Dxh)
<nul set /p"= %%j")
set /a count+=1
)
echo.)>>"%~dp0test_.bat"
2>nul del /a /f cmp_.ps
set /a str=size-15
set "data=rcx ^!h^! "n tmp_" w q"
:Dxh
set /a str+=16
set h=
(for /l %%i in (1 1 8) do (
if !str! GTR 0 (
set /a "n=str&15,str>>=4"
call set h=%%hx:~!n!,1%%!h!
)
)
set str=%str%)
(for %%i in (%data%) do (>>"%~dp0test_.bat" echo.%%~i))&&goto :End
if %count% neq 0 echo.
<nul set /p"=e %h%"
goto :eof
:End
echo.文件编码成功!
echo.
echo.新文件绝对路径:%~dp0test_.bat
echo.
pause
exit/b
[