标题: [文件操作] 这俩批处理怎么和一块 ,查到并生成桌面快捷方式? [打印本页]
作者: asdfasdf 时间: 2024-6-21 20:58 标题: 这俩批处理怎么和一块 ,查到并生成桌面快捷方式?
◆◆◆◆◆◆◆◆第一个是查找替换的BAT挺好用的,- @echo off
- if "%1" == "h" goto begin
- mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
- :begin
- REM
- ::记住单前路径 以上静默
- set aa=%cd%
- ::所有盘符走一遍
- for %%b in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
- cd /d %%b:\
- echo %cd%
- ::遍历磁盘查找2222文件 并判断 路径里是否含有 \1111\2222
- for /f "delims=" %%c in ('dir /s /b "2222"^|find /i "\1111\2222"') do (
- ::找到\ABC\ABC.TXT 后进行替换
- xcopy "%aa%\2222" "%%c"/s /y
- )
- )
复制代码
◆◆◆◆◆◆◆◆下面这个是生成桌面快捷方式的BAT用着也行- @echo off
- ::设置程序或文件的完整路径(必选)
- set Program=E:\实验\1111\2222\1221.txt
- ::设置快捷方式名称(必选)
- set LnkName=快捷方式222
- ::设置程序的工作路径,一般为程序主目录,此项若留空,脚本将自行分析路径
- set WorkDir=
- ::设置快捷方式显示的说明(可选)
- set Desc=测试
- if not defined WorkDir call:GetWorkDir "%Program%"
- (echo Set WshShell=CreateObject("WScript.Shell"^)
- echo strDesKtop=WshShell.SpecialFolders("DesKtop"^)
- echo Set oShellLink=WshShell.CreateShortcut(strDesKtop^&"\%LnkName%.lnk"^)
- echo oShellLink.TargetPath="%Program%"
- echo oShellLink.WorkingDirectory="%WorkDir%"
- echo oShellLink.WindowStyle=1
- echo oShellLink.Description="%Desc%"
- echo oShellLink.Save)>makelnk.vbs
- echo 桌面快捷方式创建成功!
- makelnk.vbs
- del /f /q makelnk.vbs
- exit
- goto :eof
- :GetWorkDir
- set WorkDir=%~dp1
- set WorkDir=%WorkDir:~,-1%
- goto :eof
复制代码
这俩怎么和一块 ,在不知道路径的情况下,查到并生成桌面快捷方式,,,,新人寻求帮助
作者: ShowCode 时间: 2024-6-22 08:59
回复 1# asdfasdf - @echo off
- if "%1" == "h" goto :begin
- mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
-
- :begin
- set aa=%cd%
- REM 所有盘符走一遍
- for %%b in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
- cd /d %%b:\
- echo %cd%
- REM 遍历磁盘查找 1221.txt 文件 并判断 路径里是否含有 \1111\2222
- for /f "delims=" %%c in ('dir /s /b "1221.txt" ^| find /i "\1111\2222"') do (
- echo 找到文件 %%c
- call :CreateShortcut "%%c"
- goto :eof
- )
- )
- goto :eof
-
- :CreateShortcut
- REM 设置程序或文件的完整路径(必选)
- set "Program=%~1"
- REM 设置快捷方式名称(必选)
- set "LnkName=快捷方式222"
- REM 设置程序的工作路径,一般为程序主目录,此项若留空,脚本将自行分析路径
- set "WorkDir="
- REM 设置快捷方式显示的说明(可选)
- set "Desc=测试"
- if not defined WorkDir call :GetWorkDir "%Program%"
- (echo Set WshShell=CreateObject("WScript.Shell"^)
- echo strDesKtop=WshShell.SpecialFolders("DesKtop"^)
- echo Set oShellLink=WshShell.CreateShortcut(strDesKtop^&"\%LnkName%.lnk"^)
- echo oShellLink.TargetPath="%Program%"
- echo oShellLink.WorkingDirectory="%WorkDir%"
- echo oShellLink.WindowStyle=1
- echo oShellLink.Description="%Desc%"
- echo oShellLink.Save)>makelnk.vbs
- makelnk.vbs
- echo 桌面快捷方式创建成功!
- del /f /q makelnk.vbs
- goto :eof
-
- :GetWorkDir
- set "WorkDir=%~dp1"
- set "WorkDir=%WorkDir:~,-1%"
- goto :eof
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |