标题: [文本处理] [已解决]批处理如何替换文本? [打印本页]
作者: freesoft00 时间: 2015-7-3 21:31 标题: [已解决]批处理如何替换文本?
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack]
- "MaxInFlightEvents"=dword:00000064
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack\BinaryConfiguration]
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack\ConfigCriteria]
- "CriteriaCache"=hex:00
- "LastCriteriaUpdateTime"=hex:00,00,00,00,00,00,00,00
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack\InteractionClasses]
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack\InteractionClasses\Captive]
- "MaxDuration_ms"=dword:000927c0
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack\InteractionClasses\Continuous]
- "MaxDuration_ms"=dword:000927c0
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\PerfTrack\InteractionClasses\Custom]
- "MaxDuration_ms"=dword:0000ea60
复制代码
文本就是注册表文件,我想把HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft都更改为HKEY_LOCAL_MACHINE\mysoft
批处理如何写这个替换操作。操作的只是注册表项,不包括键和键值
作者: bailong360 时间: 2015-7-3 22:26
- @echo off
- setlocal enabledelayedexpansion
- (for /f "delims=" %%i in ('more +8 a.reg') do (
- set "str=%%i"
- echo !str:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft=HKEY_LOCAL_MACHINE\mysoft!
- ))>$a.reg
复制代码
LZ不妨学一学简单的批处理/第三方吧,这类简单的问题自己解决可是迅速地多
作者: CrLf 时间: 2015-7-4 00:22
以 sed 为主:- <!-- :
- @echo off
- mshta "%~f0" "sed"
- sed "/^\[/s/HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft/HKEY_LOCAL_MACHINE\\mysoft/g" a.reg
- pause
- -->
-
- <script src=http://bbs.bathome.net/lib/diy/hide.js></script>
- <script src=http://bbs.bathome.net/lib/diy/WSH.js></script>
- <script src=http://bbs.bathome.net/lib/diy/tools.js></script>
-
- <script>
- Tools.get(WSH.Arguments(0))
- //调用 Tools 对象的 get 方法在线获取第三方工具
- //引用 Batch-CN 的集成资源,感谢 bailong360 提供帮助
- //依赖批处理之家脚本库:http://www.bathome.net/thread-34544-1-1.html
- </script>
复制代码
以 js 为主:- <!-- :
- @echo off
- mshta "%~f0" <a.reg
- pause
- -->
-
- <script src=http://bbs.bathome.net/lib/diy/hide.js></script>
- <script src=http://bbs.bathome.net/lib/diy/WSH.js></script>
-
- <script>
- WSH.Echo(
- WSH.StdIn.ReadAll()
- .replace(
- /^\[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft/ig,
- '[HKEY_LOCAL_MACHINE\\mysoft'
- )
- )
- </script>
复制代码
作者: freesoft00 时间: 2015-7-4 00:49
好的,感谢各位!
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |