Question : Batch file to add and remove ; from a text.ini file

Greetings,

I have a text.ini file that feeds to an application what database it should be logged to.

I need to create a Batch file that edits the following based on input from the user, so that they can flip back and forth between databases with out having to go into the ini file themselves.

(Current text.ini)

Database Name = Test123
;Database Name = Test456

If they enter test123 and there is no ; leave it alone, if there is a ; remove the semi colon and add the semi colon to the Test456 and save the .ini

If they enter Test456, it again looks to see if the semi colon is present, if not, leave it alone, if it is remove it and add it to the other line and save the .ini

The prompt would ask for which database they wish to access Test123 or Test456, then proceed to edit the ini file as needed.

Personally its easy for me to edit the file manually, doing so scares my other coworkers. Hence the batch file request.

Thank you
Julie

Answer : Batch file to add and remove ; from a text.ini file

Oops! Please change the following group of lines (in the 'display current database setting' section) - it gives a neater output in the event 2 or more databases happen to be already set:


      echo ERROR: Multiple current databases set
      for /l %%i in (1,1,!total_current_databases!) do (
         echo !Current_DataBase[%%i]!
      )


to:


      echo ERROR: Multiple current databases set
      echo.
      for /l %%i in (1,1,!total_current_databases!) do (
         echo     !Current_DataBase[%%i]!
      )
Random Solutions  
 
programming4us programming4us