INI Value to Batch Value

Microsoft Windows xp professional w/serv...
June 21, 2010 at 21:20:32
Specs: Windows XP Pro
I would like to pull the value from an INI file (which is a batch file) and then add a new line of text/command to this batch file.

config.ini contains

I would like to create a new batch file called UpdateSchedule.bat. This file will insert an addtional command into the existing shedule.bat at line 50. (Line 50 will @CALL anotherbatch.bat)

What I require is the ability to pull the value (filename) from the AUTOLAUNCH parameter to tell the UpdateSchedule.bat what the file name is and to add the new code at line 50 as the AUTOLAUNCH value is different on varying instances of the config.ini file (i.e. it is not the same name on every PC that will need this update)

Thank you for any help you may have.

See More: INI Value to Batch Value

Report •

June 23, 2010 at 12:34:55
Adjust app_path and batch_path accordingly...


SET app_path=\Your\Path\To
SET batch_path=\Your\Path\To
SET temp_batch=tmp%RANDOM%tmp.bat

FOR /F "usebackq tokens=1* delims==" %%a IN ("%app_path%\config.ini") DO (
    IF /I "%%a" EQU "AUTOLAUNCH" (
        SET autolaunch_batch=%%b

SET /A line_counter=0
FOR /F "usebackq delims=" %%a IN ("%batch_path%\!autolaunch_batch!") DO (
    SET /A line_counter+=1
    SET no_redundancy=%%a
    SET no_redundancy=!no_redundancy:~0,5!
    IF !line_counter! EQU 50 (
        IF /I "!no_redundancy!" NEQ "@CALL" (
            >>"%batch_path%\%temp_batch%" ECHO @CALL "%batch_path%\anotherbatch.bat"
    >>"%batch_path%\%temp_batch%" ECHO %%a
MOVE /Y "%batch_path%\%temp_batch%" "%batch_path%\!autolaunch_batch!"

I added the "no_redundancy" part in, so if the "autolaunch" batch file already has @CALL at line 50, it will prevent having @CALL anotherbatch.bat added multiple times, if UpdateSchedule.bat is run multiple times on the same machine.

Insomniac at large

Report •

June 28, 2010 at 22:06:10
Wow! Thank you so very much. Truly Amazing!

Report •
Related Solutions

Ask Question