本帖最后由 yyz219 于 2022-6-28 11:40 编辑
右键添加新建bat文件.bat- @echo off
-
- reg add "HKCR\.bat\ShellNew" /f /v "NullFile" /t REG_SZ /d ""
- reg add "HKCR\.bat\ShellNew" /f /v "Data" /t REG_SZ /d "@echo off"
- ::【给 新建的bat文件一个名字】
- reg add "HKCR\batfile" /f /v "FriendlyTypeName" /t REG_SZ /d "bat 文件"
- ::【给 新建的bat文件加头尾】
- >"temp.vbs" echo Set WshShell = WScript.CreateObject("WScript.Shell")
- >>"temp.vbs" echo regKey = "HKEY_CLASSES_ROOT\.bat\ShellNew\"
- >>"temp.vbs" echo Text = "@echo off" ^& VbCrLf ^& "" ^& VbCrLf ^& "pause >nul" ^& VbCrLf ^& "exit"
- >>"temp.vbs" echo WshShell.RegWrite regKey ^& "Data", Text, "REG_SZ"
- temp.vbs
- del /q temp.vbs
- exit
-
- ::【其中】
- >>"temp.vbs" echo Text = "添加第一行" ^& VbCrLf ^& "添加第二行" ^& VbCrLf ^& "添加第三行" ^& VbCrLf ^& "添加第四行"
复制代码 删除右键bat.bat- @echo off
-
- reg delete "HKCR\.bat\ShellNew" /f
-
- exit
复制代码 效果:- @echo off
-
- pause >nul
- exit
复制代码
|