Advertisement
jcunews

AddGroup.bat

Apr 21st, 2021 (edited)
1,830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.19 KB | None | 0 0
  1. @echo off
  2. set inifile=c:\windows\progman.ini
  3. set groupfile=c:\myprog\myprog.grp
  4. set n=1
  5. if not exist %inifile% goto found
  6.  
  7. :chk
  8. rem below code will check up to group number 20.
  9. rem add more group number condition check code if needed.
  10. >nul type %inifile% | find "Group%n%="
  11. if errorlevel 1 goto found
  12. if %n% == 20 goto toomany
  13. if %n% == 19 set n=20
  14. if %n% == 18 set n=19
  15. if %n% == 17 set n=18
  16. if %n% == 16 set n=17
  17. if %n% == 15 set n=16
  18. if %n% == 14 set n=15
  19. if %n% == 13 set n=14
  20. if %n% == 12 set n=13
  21. if %n% == 11 set n=12
  22. if %n% == 10 set n=11
  23. if %n% == 9 set n=10
  24. if %n% == 8 set n=9
  25. if %n% == 7 set n=8
  26. if %n% == 6 set n=7
  27. if %n% == 5 set n=6
  28. if %n% == 4 set n=5
  29. if %n% == 3 set n=4
  30. if %n% == 2 set n=3
  31. if %n% == 1 set n=2
  32. goto chk
  33.  
  34. :found
  35. echo Next group number is %n%.
  36. rem add [Groups] section if not yet exist
  37. if not exist %inifile% goto addsection
  38. >nul type %inifile% | find "[Groups]"
  39. if not errorlevel 1 goto addgroup
  40.  
  41. :addsection
  42. >>%inifile% echo [Groups]
  43.  
  44. :addgroup
  45. >>%inifile% echo Group%n%=%groupfile%
  46. goto end
  47.  
  48. :toomany
  49. echo Can't find next available group number. Too many groups to check.
  50. echo Please add more group number condition check code.
  51.  
  52. :end
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement