bat 和 vbs 笔记

代码 · 2022-03-13 · 209 人浏览

bat 多按键实例

@ECHO OFF
ECHO CreateObject("WScript.Shell").SendKeys "{F5}">>%Temp%\F5.vbs
ECHO CreateObject("WScript.Shell").SendKeys "+{F10}">>%Temp%\F5.vb
ECHO CreateObject("WScript.Shell").SendKeys "V">>%Temp%\F5.vbs
ECHO CreateObject("WScript.Shell").SendKeys "D">>%Temp%\F5.vbs
cscript /nologo %Temp%\F5.vbs

vbs多按键实例

set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{F5}"
WScript.sleep 1000
WshShell.SendKeys "{F5}"
WshShell.SendKeys "+{F10}"
WshShell.SendKeys "V"
WshShell.SendKeys "D"

目录树

tree /f >D:\1.txt
D:\1.txt为保存路径

检查文件夹里的文本是否包含内容

@echo off 
setlocal EnableDelayedExpansion
for /r "D:\Mirserver\Mir200\Envir\MonItems\" %%a in (*.txt) do (
find "匕首" %%a
if "!errorlevel!"=="0" echo %%a >>d:\include_name垃圾史诗.txt 
)
setlocal DiskableDelayedExpansion
echo 已完成,路径保存在d:\include_name垃圾史诗.txt
pause >nul

批量在文件头添加文字

@echo off
title 批量替换文件名 
echo.
echo 本批处理可批量替换本文件所在文件夹下所有文件的文件名。
echo.
echo.&set /p strtemp3= 请输入要添加前缀的文件类型:
echo.&set /p strtemp2= 请输入要添加前缀的文件名字符串(不变则直接回车):
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /a /b *.%strtemp3%') do (
ren "%%~a" "%strtemp2%_%%a")
for /f "delims=" %%a in ('dir /a /b *"批量改工具".bat') do (
ren "%%~a" "批量改工具.bat")
echo.
echo OK了!
echo.
pause
Theme Jasmine by Kent Liao