码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Windows下使用Bat文件杀死进程


    输入端口号杀死进程

    新建一个“kill port.bat”文件

    1. @echo off
    2. rem open var delay
    3. setlocal enabledelayedexpansion
    4. rem recev var
    5. set /p port=请输入端口号
    6. if "%port%" == "" (
    7. echo Please enter port
    8. goto end
    9. )
    10. echo ---------------start find who is using port %port%-----------------------
    11. rem Add colon before port and space after port to ensure no mistake
    12. for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port% "') do (
    13. rem a is protocol,b is local ip:port, c is remote ip:port,d is state or pid,e is pid or null
    14. echo %%a %%b %%c %%d %%e
    15. rem Cut the %%b with the : to get the port
    16. for /f "delims=:, tokens=1-2" %%j in ("%%b") do (set destport=%%k)
    17. rem Delay variable in for loop must use! Symbol instead of% symbol
    18. echo The port found here is !destport!. What we need is %port%
    19. rem If %%b cuts the same port as the target port
    20. if "!destport!" equ "%port%" (
    21. if "%%e" == "" (
    22. rem sometimes e is empty pid in d
    23. if not "%%d" == "0" (
    24. echo get d col pid %%d
    25. set pid=%%d
    26. )
    27. ) else (
    28. if not "%%e" == "0" (
    29. echo get e col pid %%e
    30. set pid=%%e
    31. )
    32. )
    33. ) else (
    34. echo this row local not use port %port%
    35. )
    36. )
    37. echo ---------------end find who is using port %port%-----------------------
    38. if "%pid%"=="" (
    39. echo Port %port% is not in use
    40. ) else (
    41. echo used port %port% the process %pid%
    42. taskkill /f /pid %pid%
    43. )
    44. pause
    45. :end
    46. echo ---------------end----------------------------------------------------

  • 相关阅读:
    先进制造aps专题四 计划型简单aps系统(plan)和排产型复杂aps系统(Scheduling)的区别
    POJO>JavaBean
    实现分片上传、断点续传、秒传 (JS+NodeJS)(TypeScript)
    js实现转义、反转义
    目标检测入门
    一文真正学懂java接口
    redis
    城商行两地三中心存储架构设计实践分享
    java后端修改日期格式
    Sleuth链路追踪,Zipkin集成
  • 原文地址:https://blog.csdn.net/qiandeqiande/article/details/134501332
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号