标题: [其他] 使用批处理替换功能,替换出来的内容为何消失了? [打印本页]
作者: mmh1 时间: 2012-12-4 10:53 标题: 使用批处理替换功能,替换出来的内容为何消失了?
- del 1.txt
- for /f "tokens=1,2,3,4,5,6 delims=:" %%i in ('wmic nic where "netconnectionid='本地连接 2'" get macaddress') do set q=%%i-%%j-%%k-%%l-%%m-%%n
- set /s aa=%q%
- pause
- for /f "delims=" %%a in (ptc_licfile.dat) do (
- set str=%%a
- setlocal enabledelayedexpansion
- set "str=!str:00-23-8B-BF-5F-E8=%aa%!"
- echo,!str:*:=!
- endlocal
- )>>1.txt
复制代码
ptc_licfile.dat 内容:
INCREMENT MECBASICUI_12345 ptc_d 29.0 permanent uncounted \
VENDOR_STRING="VSVER=2.0 LO=(19,157,211)" SUPERSEDE HOSTID=PTC_HOSTID=00-23-8B-BF-5F-E8 \
vendor_info="VIVER=2.0 EXTERNAL_NAME=" ISSUER=ODT \
ISSUED=2-apr-2006 NOTICE=PTC SN=07071982 SIGN="092F DBD8 F7BA \
EC9D 51E5 453C 93A1 D63D 0BC7 3126 8493 2C23 32A9 A98F 8BC0 1BEB \
0F0F 5C63 6933 5B61 613F 0CFB 235B 9C1B B39E 274F 2E5A 60E1 1FEF \
DE6A" SIGN2="092F DBD8 F7BA EC9D 51E5 453C 93A1 D63D 0BC7 3126 \
8493 2C23 32A9 A98F 8BC0 1BEB 0F0F 5C63 6933 5B61 613F 0CFB 235B \
9C1B B39E 274F 2E5A 60E1 1FEF DE6A"
为什么替换了就没了?
作者: mmh1 时间: 2012-12-4 11:39
del 1.txt
for /f "tokens=1,2,3,4,5,6 delims=:" %%i in ('wmic nic where "netconnectionid='本地连接 2'" get macaddress') do set q=%%i-%%j-%%k-%%l-%%m-%%n
set aa=%q%
for /f "delims=" %%a in (ptc_licfile.dat) do (
set str=%%a
setlocal enabledelayedexpansion
set "str=!str:00-23-8B-BF-5F-E8=%aa%!"
echo,!str:*:=!
endlocal
)>>1.txt
pause
改成这样,后面又多了两个空格。。。。。。
纠结啊
作者: apang 时间: 2012-12-4 14:43
本帖最后由 apang 于 2012-12-4 14:45 编辑
试试这样:- @echo off
- for /f "tokens=2 delims==" %%i in ('wmic nic where "netconnectionid='本地连接 2'" get macaddress /value^|find "="') do set "q=%%i"
- set "q=%q::=-%"
- (for /f "delims=" %%a in (ptc_licfile.dat) do (
- set "str=%%a"
- setlocal enabledelayedexpansion
- set "str=!str:00-23-8B-BF-5F-E8=%q%!"
- echo,!str!
- endlocal
- ))>1.txt
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |