Guest User

Untitled

a guest
Jul 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. :main
  5. pushd %~dp0
  6.  
  7. rem set arguments
  8. set arg1=%1
  9. set arg2=%2
  10.  
  11. rem check arguments
  12. call :check_arg1 %arg1%
  13. call :check_arg2 %arg2%
  14.  
  15. rem import ini files
  16. set ini=test.ini test2.ini
  17. for %%i in (%ini%) do call :import_ini %%i
  18.  
  19. rem body
  20. echo arg1=%arg1%
  21. echo arg2=%arg2%
  22. echo temp=%temp%
  23. echo temp2=%temp2%
  24.  
  25. popd
  26. exit /b
  27.  
  28. :check_arg1
  29. if "%1" == "a" (
  30. rem something to do
  31. ) else if "%1" == "b" (
  32. rem something to do
  33. ) else (
  34. echo ERROR : wrong argument arg1=%arg1%
  35. exit
  36. )
  37. exit /b
  38.  
  39. :check_arg2
  40. if "%1" == "a" (
  41. rem something to do
  42. ) else if "%1" == "b" (
  43. rem something to do
  44. ) else (
  45. echo ERROR : wrong argument arg2=%arg2%
  46. exit
  47. )
  48. exit /b
  49.  
  50. :import_ini
  51. for /f "tokens=1,2* delims==" %%i in (%1) do (
  52. if not %%i == # (
  53. set %%i=%%j
  54. )
  55. )
  56. exit /b
  57.  
  58. endlocal
Add Comment
Please, Sign In to add comment