问题完美解决:- @echo off
- del 1.txt 2.>nul
- set /p M=<lnk路径.txt
- for /f "tokens=*" %%i in (快捷方式-模板.txt) do call :begin "%%i"
- start notepad 1.txt
- goto :eof
- :begin
- set var=%~1
- if defined var call set var=%%var:lnk路径=%M%%%
- if defined var echo %var%>>1.txt
复制代码
********************************************************
原来的问题:
1.现有批处理(替换文本指定内容.bat)(待修改)代码:- @echo off
- del 1.txt
- set /p M=<lnk路径.txt
- for /f "tokens=*" %%i in (快捷方式-模板.txt) do call :begin ^"%%i^"
- start notepad 1.txt
- goto :eof
- :begin
- set var=%~1
- if defined var set var=%var:lnk路径=%%M%% %
- if defined var echo %var% >> 1.txt
复制代码 2.目的是:用 “lnk路径.txt” 里面的内容 去替换 “快捷方式-模板.txt” 里面的 lnk路径
3.快捷方式-模板.txt内容是:- Set WshShell = WScript.CreateObject("WScript.Shell")
- set oShellLink = WshShell.CreateShortcut("lnk路径")
复制代码 4.lnk路径.txt里面的内容(变化的,可能有空格):
D:\桌面\Desktop\Dism++.lnk
***************************************************
5.运行批处理以后,1.txt内容:- Set WshShell = WScript.CreateObject("WScript.Shell")D:\桌面\Desktop\Dism++.lnk
- set oShellLink = WshShell.CreateShortcut("")D:\桌面\Desktop\Dism++.lnk
复制代码 6.期待结果是:- Set WshShell = WScript.CreateObject("WScript.Shell")
- set oShellLink = WshShell.CreateShortcut("D:\桌面\Desktop\Dism++.lnk")
复制代码
|