zoukankan      html  css  js  c++  java
  • 修改ini文件的批处理

    用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
    
    
    批处理代码:
    
    @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 

    批处理打开和关闭文件

    关闭 两种命令方法:
    
    taskkill /f im "要关闭的进程名"
    
    ntsd -c q -pn "要关闭进程名"
    
    后者更强一点..~!
    
    打开程序:
    
    start "" “位置/程序名”

    
    
  • 相关阅读:
    hdoj:2033
    hdoj:2032
    hdoj:2031
    hdoj:2029
    hdoj:2028
    hdoj:2027
    hdoj:2024
    hdoj:2023
    hdoj:2022
    hdoj:题目分类
  • 原文地址:https://www.cnblogs.com/qmfsun/p/6863417.html
Copyright © 2011-2022 走看看