0
点赞
收藏
分享

微信扫一扫

win10批处理 替换文件内容IP


注:

1.以下代码只能保存为bat使用 命令行使用需要把%% 换为%

2.以管理员运行此脚本

@echo off & setlocal EnableDelayedExpansion

SET IP=172.16.203.59

::永久设置中文编码
SET path= HKEY_CURRENT_USER\Console\%%SystemRoot%%_system32_cmd.exe
reg.exe ADD %path% /v "CodePage" /t REG_DWORD /d "65001"

::创建临时文件
SET temp_file= C:\temp.txt
type nul> %temp_file%

::替换文件 内容JS的IP
SET neirong_path=C:\edsip\nginx-1.12.2\html\neirong\static\lib\ipconfig.js
for /f "delims=" %%b in ('type %neirong_path%') do (
set "str=%%b"&set "str=!str:127.0.0.1=%IP%!"
echo !str! >> %temp_file%
)
::覆盖文件
copy %temp_file% %neirong_path% /y

::打开 内容JS 设备JS
notepad %neirong_path%

::清空零时文件
type nul> %temp_file%
pause





举报

相关推荐

0 条评论