Board logo

标题: 高手帮忙完善一下这个批处理 [打印本页]

作者: eech     时间: 2006-12-1 07:18    标题: 高手帮忙完善一下这个批处理

原文件:出自不得不爱 http://photo.bababian.com/200611 ... 3AB416B3007F228.jpg 超级版主     "sz.reg转换成reg.bat的批处理"

@echo off
for /f "tokens=*" %%a in ('type sz.reg') do echo echo %%a^>^>tmp.reg>>reg.bat
echo echo regedit /s tmp.reg>>reg.bat

下面是我的测试
转换前注册表文件:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]
"Attributes"=hex:50,01,00,20
"CallForAttributes"=dword:00000040

转换后批处理文件:
echo Windows Registry Editor Version 5.00>>tmp.reg
echo [HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]>>tmp.reg
echo "Attributes"=hex:50,01,00,20>>tmp.reg
echo "CallForAttributes"=dword:00000040>>tmp.reg
echo regedit /s tmp.reg


这是我的问题:
如何让转换的批处理文件第一行前自动加上@echo off
最后一行自动加上
rename tmp.txt tmp.reg
start /wait regedit /s tmp.reg
del /q tmp.reg
exit

[ Last edited by eech on 2006-12-1 at 07:22 AM ]
作者: lxmxn     时间: 2006-12-1 07:34

@echo off
echo @echo off>>reg.bat
for /f "tokens=*" %%a in ('type sz.reg') do echo echo %%a^>^>tmp.reg>>reg.bat
echo rename tmp.txt tmp.reg>>reg.bat
echo start /wait regedit /s tmp.reg>>reg.bat
echo del /q tmp.reg>>reg.bat
echo exit>>reg.bat

作者: eech     时间: 2006-12-1 09:12
http://photo.bababian.com/200611 ... 4BD49415938E1DE.jpg

窗口有错误提示.附图.如果能完善一下就好了.是不是太贪心了.谢谢大侠
作者: lxmxn     时间: 2006-12-1 09:40

@echo off
echo @echo off>>reg.bat
for /f "tokens=*" %%a in ('type sz.reg') do echo echo %%a^>^>tmp.reg>>reg.bat
echo start /wait regedit /s tmp.reg>>reg.bat
echo del /q tmp.reg>>reg.bat
echo exit>>reg.bat

作者: bootp     时间: 2006-12-1 10:16
不用改名,reg.txt照样可以导入的。