Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set inifile=c:\windows\progman.ini
- set groupfile=c:\myprog\myprog.grp
- set n=1
- if not exist %inifile% goto found
- :chk
- rem below code will check up to group number 20.
- rem add more group number condition check code if needed.
- >nul type %inifile% | find "Group%n%="
- if errorlevel 1 goto found
- if %n% == 20 goto toomany
- if %n% == 19 set n=20
- if %n% == 18 set n=19
- if %n% == 17 set n=18
- if %n% == 16 set n=17
- if %n% == 15 set n=16
- if %n% == 14 set n=15
- if %n% == 13 set n=14
- if %n% == 12 set n=13
- if %n% == 11 set n=12
- if %n% == 10 set n=11
- if %n% == 9 set n=10
- if %n% == 8 set n=9
- if %n% == 7 set n=8
- if %n% == 6 set n=7
- if %n% == 5 set n=6
- if %n% == 4 set n=5
- if %n% == 3 set n=4
- if %n% == 2 set n=3
- if %n% == 1 set n=2
- goto chk
- :found
- echo Next group number is %n%.
- rem add [Groups] section if not yet exist
- if not exist %inifile% goto addsection
- >nul type %inifile% | find "[Groups]"
- if not errorlevel 1 goto addgroup
- :addsection
- >>%inifile% echo [Groups]
- :addgroup
- >>%inifile% echo Group%n%=%groupfile%
- goto end
- :toomany
- echo Can't find next available group number. Too many groups to check.
- echo Please add more group number condition check code.
- :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement