Source code of Windows XP (NT5)
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.

71 lines
1.6 KiB

  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. for %%a in (.- ./ .) do if /i ".%1." == "%%a?." goto :Usage
  4. call logmsg.cmd /t "Beginning ..."
  5. REM set local vars
  6. set /a ExitCode=0
  7. set BuildName=%1
  8. if not defined BuildName (
  9. call errmsg.cmd "No build name given, exiting."
  10. set /a ExitCode=!ExitCode! + 1
  11. goto :Usage
  12. )
  13. net files >nul 2>nul
  14. if "!ErrorLevel!" NEQ "0" (
  15. call logmsg.cmd "net file failed, exiting."
  16. set /a ExitCode=!ExitCode! + 1
  17. goto :ErrEnd
  18. )
  19. for /f "delims=#" %%a in ('net files') do (
  20. if /i "%%a" == "There are no entries in the list." (
  21. call logmsg.cmd "No files opened, exiting."
  22. goto :End
  23. )
  24. )
  25. for /f "tokens=1" %%a in ('net files') do (
  26. set /a ThisFileNum=%%a >nul 2>nul
  27. if "!ThisFileNum!" NEQ "0" (
  28. for /f "tokens=1,2" %%b in ('net file !ThisFileNum!') do (
  29. if /i "%%b" == "Path" (
  30. set ThisPath=%%c
  31. if /i not "!ThisPath!" == "!ThisPath:%BuildName%=!" (
  32. REM we found the build name in the given path
  33. net file !ThisFileNum! /close
  34. )
  35. )
  36. )
  37. )
  38. )
  39. if "!ExitCode!" NEQ "0" goto :ErrEnd
  40. goto :End
  41. :Usage
  42. echo.
  43. echo Usage: %0 ^<Build name^>
  44. echo.
  45. echo For instance, %0 2213.x86fre.main.000314-1935 will kill all open
  46. echo file connections which have the string 2213.x86fre.main.000314-1935
  47. echo in the "Path" field of a call to net file.
  48. echo.
  49. goto :EOF
  50. :End
  51. call logmsg.cmd /t "Finished."
  52. endlocal
  53. goto :EOF
  54. :ErrEnd
  55. call logmsg.cmd /t "Finished with !ExitCode! logged error(s)."
  56. if "!ExitLevel!" == "0" set /a ExitCode=1
  57. endlocal & seterror.exe "!ExitCode!"