如何给.BAT文件加密

如何给.BAT文件加密,第1张

cls

@echo off

@Title Tools code

:Key

set all= 请输入秘钥(若没有,请输入help)

set /p all=请按任意键继续(若肢胡御没有,请输入历岩help)(获取临时秘钥请发送:user):

if /i "%all%"=="help" goto Eorry

if /i "%all%"=="user" goto user

if /i "%all%"做哪=="Tools" goto Tools

:Tools

echo 请输入密码打开Tools

set/p "pass=(more than)" goto menu

if NOT %pass%== JAIXUDLW goto FAIL

echo 密码正确

goto menu

:FAIL

echo 密码无效

ping 127.0.0.1 -n 5 >nur

goto Key

:menu

echo 欢迎使用本tool code

echo 秘钥正确!

ping 127.0.0.1 -n 5 >nur

@color 4A

@mode con cols=80 lines=32

@title Me晴朗批处理制作

@echo off

echo 下面内容你自己写

给批处理加密的文件代码如下:

@ECHO off

cls

color f0

echo.

echo.

ECHO批处理文件(.bat .cmd)加密工具

echo.

echo.

echo 说明: 在下面输入需要加密的批处理文件名

echo.

echo 若在此文件的同目录下直接输入“文件名.bat”即可

echo.

echo 也可以带路径指定任意BAT

echo.

echo 加密完成后会在同目录下生成“加密成品.bat”文件

echo.

echo.

echo.

echo.

set /p file=请输入需要加密的批处理后(名+后缀)按回车键(Q=退出):

if "%file%"=="q" goto quit

echo %file%|findstr /i "\.bat$">nul &&goto go

echo %file%|findstr /i "\.cmd$">nul &&goto go

cls

echo ==============

echo 请正确输入!

echo ==============

echo.

echo.

echo 按任意键重新输入......

pause>nul

goto start

:go

if not exist "%file%" goto newly

if exist encrypt.bat copy encrypt.bat encryptbak.bat

echo %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a >"%tmp%\encrypt.tmp"

echo cls>>"%tmp%\encrypt.tmp"

type "%file%">>"%tmp%\encrypt.tmp"

setlocal enabledelayedexpansion

for %%i in ("%tmp%\encrypt.tmp") do (

echo %%~zi >nul 2>nul

set size=%%~zi

set num=!size:~-1!

set /a mod=!num!%%2

if !mod! equ 0 (goto even) else (goto odd)

)

:even

copy "%tmp%\encrypt.tmp" 加密成品.bat

del "%tmp%\encrypt.tmp"

cls

echo ===============================

echo 恭喜, 批处理加密成功!

echo ===============================

echo.

echo.

echo 按任意键退出......

pause>nul

goto quit

:odd

echo. >>"%tmp%\encrypt.tmp"

copy "%tmp%\encrypt.tmp" 加密成品.bat

del "%tmp%\encrypt.tmp"

cls

echo ===============================

echo 恭喜, 批处理加密成功!

echo ===============================

echo.

echo.

echo 按任意键退出......

pause>nul

goto quit

:newly

cls

echo ================================

echo 找不到批处理文件, 请重新输入!

echo ================================

echo.

echo.

echo 按任意键开始......

pause>nul

goto start

:quit

exit

您可以使用以下 bat 脚本来实现上述功能:

@echo off

for /d %%d in (*) do (

"C:\Program Files\Bandizip\Bandizip.exe" a -p123 -m0=lzma2 -mx=9 -y "%%d.7z" "%%d\"

)

echo Done.

上面的脚本会遍历当前目录下的所有文件夹,并使用 Bandizip 进行加辩手册携宏密压缩。密码为 123,压缩算法为 LZMA2,最高压缩级别为 9,-y 参薯罩数用于在不询问的情况下覆盖已存在的压缩包。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12243228.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-22
下一篇 2023-05-22

发表评论

登录后才能评论

评论列表(0条)

保存