- 帖子
- 10
- 积分
- 17
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2010-8-16
|
3楼
发表于 2010-8-17 16:00
| 只看该作者
谢谢楼上的,正解,确实是pro/e密匙,想把它绿化到移动硬盘或者u盘里去,我看了无数网页,自己写了一个,但最后有一些问题,先付1.txt文件及代码
1.txt文件
#REPLACE ALL 00-00-00-00-00-00 WITH YOURSELF PTC_HOST_ID
INCREMENT PROE_200 ptc_d 30.0 permanent uncounted \
EC7498757755369A3446 VENDOR_STRING="VSVER=2.0 \
LO=(0,3,6,7,9,10,14,16,17,19,21,22, \
23,24,25,26,29,30,31,32,34,35,36,37,40,41,45,47,48,51,52,53, \
54,55,56,57,59,60,61,62,63,65,66,67,69,71,72,73,74,77,91,92, \
93,94,97,100,104,106,108,115,116,117,118,119,120,121,122,123,125, \
126,127,128,131,133,134,135,137,139,140,141,148,155,156,157,158, \
159,160,161,163,164,167,168,187,188,189,190,191,192,193,194,195, \
196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,213,214,218,219,220,221, \
222,223,224,225,226,227,228,229,230,235,236,237,238,239,240,241,242,243,244,245,246,247, \
248,249,250,251,253,254,255,256,257,259,260,261,262,263,264,265,266,267,268,269,270,271, \
272,273,274,275,276,277,278)" \
HOSTID=PTC_HOSTID=00-00-00-00-00-00 SUPERSEDE \
vendor_info="VIVER=2.0 EXTERNAL_NAME=" ISSUER=Ghost/ZWT \
ISSUED=30-JAN-2008 NOTICE=ZWT SN=88888888 TS_OK SIGN2="0026 \
E605 D6D0 3FBD 2114 EEB5 7A87 1D8E DDF0 D3C7 4C49 D153 1E77 \
DF8C 61A1 091E B91F 662C 15EE EBAA B0F3 0A46 7A57 B345 8BAD \
D2EB 554D 3A4F C587 7F38"……………………一下还有N多不贴啦,其中00-00-00-00-00-00 是原始MAC地址
bat代码
@echo off
for /f "tokens=1,2 delims= " %%a in ('getmac^|find /i "-"') do (set newmac=%%a)
::提取当前主机mac赋值到newmac
for /f "tokens=1,* delims=:" %%i in ('findstr/n .* 1.txt') do (
if %%i equ 1 set on1=%%j)
set oldmac=%on1:~13,17%
::提取1.txt文件中mac特征字符赋值到oldmac
(for /f "usebackq delims=" %%a in (1.txt) do (
set v=%%a
::读取1.txt文件到v中
setlocal enabledelayedexpansion
set v=!v:%oldmac%=%newmac%!
::用当前主机mac替换1.txt中mac字符
echo.!v!
endlocal
))> 1.txt
::保存替换后的文件到1.txt
问题来啦,最后保存替换后的文件到1.txt是一个0字节的文件,若保存为2.txt或者其他任意文件名都可以的,也即是说我想得到替换后1.txt可以先把原始文件改名成2.txt,然后查找替换2.txt生成1.txt。这样虽然可以但违背了我的设计意图,原始文件中的mac就不会变动,也就没必要用代码来提取原始文件的mac啦。我想要的就是原始文件是1.txt,得到替换后的1.txt文件,高手帮忙斧正一下代码啊,谢谢啦!
[ 本帖最后由 qcll 于 2010-8-17 19:27 编辑 ] |
|