@echo off >tmp.ini for /f "tokens=1* delims=:" %%i in ('findstr /n ".*" 文件位置') do ( if "%%j"=="" (echo.>>tmp.ini) else ( echo %%j|find "被替換內容">nul&&( call set tp=%%j&call echo %%tp:被替換內容=替換內容%%>>tmp.ini)||( >>tmp.ini echo %%j) ) ) copy tmp.ini 文件位置 /y >nul||(attrib -s -a -r -h 文件位置& copy tmp.ini 文件位置 /y >nul) del tmp.ini pause
用VBS更簡單:
vbs代碼:
On Error Resume Next Dim Fso,TxtFl,Str Set Fso = CreateObject("Scripting.FileSystemObject") Set TxtFl = Fso.OpenTextFile ("文件位置",1) Str = Replace ( TxtFl.ReadAll,"被替換內容","替換內容") Set TxtFl = Fso.OpenTextFile ("文件位置",2) TxtFl.Write Str TxtFl.Close
批處理打開和關閉文件
關閉 兩種命令方法:
taskkill /f im "要關閉的進程名"
ntsd -c q -pn "要關閉進程名"
后者更強一點..~!
打開程序:
start "" “位置/程序名”