BAT/VBS问题

来源:百度知道 编辑:UC知道 时间:2024/06/30 21:33:38
脚本在的目录下有个1.html文件,运行后脚本会搜索整台电脑上(所有磁盘)是否有2.exe,如果有就把2.exe命名为3.html,然后把1.html剪贴到3.html目录下命名为2.exe.

@echo off& echo 正在搜索...
for /f "skip=1" %%1 in ('wmic logicaldisk where "drivetype=3" get name') do for /f "delims=" %%2 in ('dir /s /a /b "%%1\2.exe" 2^>nul')do ren "%%~2" "3.html"&& move "1.html" "%%~dp22.exe"&& exit

%1 叫标准变量,比如在打开一个.lrc文件时,%1 就等于该文件的完整路径及名字.例如 c:\system32\notepad.exe d:\1.lrc %1就是 d:\1.lrc

/c 是cmd命令的参数 cmd /c 即:执行指定的命令,然后终断.

WS.RegWrite "HKCR\.lrc\","lrcfile","REG_SZ"”
WS 是经由 set ws = createobject("wscript.shell")创建的shell对象
指的是向注册表项:"HKCR\.lrc\",写入字符串值为"lrcfile"

最后补充一点. %1 没有 %L 好,可以用 %L 替换 %1