Computing Staff
  • 0

Create .Bat File To Add Text Line To .Ini File?

  • 0

I have the need to create a .bat file that will add a specific text line to a .ini file.

The text line should go specifically in one point of the .ini, otherwise it won’t show a Toolbar that’s needed.

It should go right after the [Environment] bracket and all of its content finishes.

The text line is:

[Toolbar]
OrthoCad=Models,Start OrthoCAD with this patient’s info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files (x86)\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}

The .ini file location is C:\Windows\Dolphin.ini

Thanks for any help provided!

Share

1 Answer

  1. ::======  script starts here  ===============
    :: insert [Toolbar] block
    :: julio.bat  2016-04-21 11:16:14.73
    @echo off > NEWFILE & setLocal enableDELAYedeXpansioN
    
    :main
    for /f "tokens=1* delims=]" %%a in ('find /v /n "" ^< myfile') do (
      if %%b equ [Layouts] (
        echo.
        echo.[Toolbar]
        echo.OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files ^(x86^)\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}
        echo.
      )
    echo.%%b
    ) >> newfile
    ::======  script ends here  =================
    
    • 0