SHARE
TWEET

Batch File Template

sweenig Jan 3rd, 2014 1,345 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. ::set default values
  3. set variable1=hello
  4. set variable2=world
  5. set variable3=0
  6. set version=0.8
  7. set lastupdated=1/3/2014
  8. ::If you want to go to help if no arguments are provided, include the following line:
  9. REM if "%1"=="" GOTO HELP
  10. if "%1"=="/?" GOTO HELP
  11. if "%1"=="?" GOTO HELP
  12. if "%1"=="help" GOTO HELP
  13. if "%1"=="Help" GOTO HELP
  14. if "%1"=="HELP" GOTO HELP
  15. if "%1"=="/h" GOTO HELP
  16. if "%1"=="--?" GOTO HELP
  17. if "%1"=="h" GOTO HELP
  18. if "%1"=="--help" GOTO HELP
  19. if "%1"=="/help" GOTO HELP
  20. :Loop
  21. IF "%1"=="" GOTO Continue
  22. IF "%1"=="/variable1" set variable1=%2
  23. IF "%1"=="/variable2" set variable2=%2
  24. IF "%1"=="/variable3" set variable3=1
  25. SHIFT
  26. GOTO Loop
  27. :Continue
  28. call:version
  29. ::--------------------------------------------------------
  30. ::-- Main program section starts below here
  31. ::--------------------------------------------------------
  32. IF %variable3% EQU 0 echo %variable1% %variable2%
  33. IF %variable3% NEQ 0 echo %variable2% %variable1%
  34. call:FUNCTION1 "Hello World!"
  35. GOTO:EOF
  36. ::--------------------------------------------------------
  37. ::-- Function section starts below here
  38. ::--------------------------------------------------------
  39. :FUNCTION1
  40. echo The function was called with argument: %~1.
  41. GOTO:EOF
  42. :HELP
  43. call:version
  44. echo batchtemplate.bat [options]
  45. echo.
  46. echo Options:
  47. echo.
  48. echo /variable1 [string]          The value for variable1 (default is %variable1%)
  49. echo /variable2 [string]          The value for variable2 (default is %variable2%)
  50. echo /variable3                   Echos the values in reverse order (set to non-zero)
  51. GOTO:EOF
  52. :version
  53. echo Version %version% - Last Updated %lastupdated%
  54. GOTO:EOF
RAW Paste Data
Top