Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. setlocal ENABLEEXTENSIONS
  5. REM *********************************************************************
  6. REM Script: ExecuteCmd.cmd
  7. REM Purpose: Primative script to be used in the cmd environment to
  8. REM execute commands with logging and error checking.
  9. REM Requires: The following vars must be set in the environment:
  10. REM %logfile%, %tmpfile%, %errfile%
  11. REM *********************************************************************
  12. REM Do not use setlocal/endlocal:
  13. REM for ex., if the command itself is "pushd",
  14. REM a "popd" will be executed automatically at the end.
  15. set cmd=%1
  16. REM Remove the quotes
  17. set cmd=%cmd:~1,-1%
  18. if "%cmd%" == "" (
  19. call errmsg.cmd "internal error: no parameters for ExecuteCmd %1."
  20. set cmd=cmd_bak& goto errend
  21. )
  22. REM Run the command.
  23. call logmsg.cmd "Running %cmd%."
  24. %cmd%
  25. if not "%errorlevel%" == "0" (
  26. call errmsg.cmd "%cmd% failed (%errorlevel%)."
  27. goto errend
  28. )
  29. goto end
  30. :errend
  31. endlocal
  32. set /a errors=errors+1
  33. seterror.exe 1
  34. goto :EOF
  35. :end
  36. endlocal
  37. seterror.exe 0
  38. goto :EOF