【批处理】如何查看进程详细信息

【批处理】如何查看进程详细信息,第1张

::以下代码仅供参考

@echo off & title 进程查看 & color 2

wmic process list full > log & tasklist /svc & echo & echo 进程路径

for /f "skip=3" %%I in ('wmic process get ExecutablePath') do (echo %%I)

echo CreateObject("ScriptingFileSystemObject")CreateTextFile("txt")WriteLine InputBox("请输入映像名称:","进程查看","smss csrss winlogon services lsass svchost explorer") > vbs & vbs

for /f %%A in (txt) do (wmic process get ExecutablePath | findstr /i %%A >txt)

for /f "delims=" %%B in (txt) do (explorer /select,%%B) & %0

bat程序里的命令是需要在command程序中运行的,所以进程名是cmdexe,这是正确的

如果你想看具体调用的什么内容,那在bat程序上右键,选编辑,就看到详细内容了

你可以这样

for /f "delims= " %%i in ('tasklist^|find /i "qqexe"') do (

if /i "%%i"=="qqexe" call cmd)如果是在批处理中运行就用%%i在CMD中就用%i他会检查进程中是否有QQexe如果有就运行CMD

@echo off

for /f "tokens=2 delims= " %%a in('tasklist^|find /i "RavMonDexe"') do (

taskkill /f /pid %%a

ntsd -c q -p %%a

)

上面这个能自动查找RavMonDexe进程的PID,并通过2种方式结束此进程

:start

@echo off&setlocal enabledelayedexpansion

title Port Mapping Viewer Lite v10

set "index=0"

set "totalPort=0"

for /f "delims=, tokens=1,2" %%a in ('tasklist /fo csv /nh') do (

set "pname_%%~b=%%~a"

)

for /f "skip=4 tokens=1,2,3,4,5" %%a in ('netstat -ano') do (

if "%%c"==":" (

set/a index+=1

set "port_!index!=%%a %%b %%d"

)

if "%%c"=="[::]:0" (

set/a index+=1

set "port_!index!=%%a %%b %%e"

)

if not "%%e"=="" (

set/a index+=1

set "port_!index!=%%a %%b %%e"

)

)

for /l %%a in (%index%,-1,1) do (

for /f "tokens=1,2,3" %%i in ("!port_%%a!") do (

for /f "delims=: tokens=2,3,6" %%o in ("%%j") do (

if "%%p"=="" (

set "port=%%o"

) else (

if "%%q"=="" (

set "port=%%p"

) else (

set "port=%%q"

)

)

)

call :print "%%i" "!port!" "%%k"

)

)

for /f "delims== tokens=1" %%i in ('set output#') do (

for /f "delims=# tokens=2,3,4" %%a in ("%%i") do (

echo [%%a ^| Pid: %%b] -^> [%%c]

)

)

echo&echo Total number of port opened: [!totalPort!]&echo

set/p "action=[Press T to exit or other keys to refresh the table] "

if /i "%action%"=="T" (

exit

)

cls

endlocal

goto start

pause

:print

set "protocol=%~1"

set "port=%~2"

set "pid=%~3"

set "process=!pname_%pid%!"

if "%process%"=="" (

set "process=Unknown"

)

if not defined %port% (

set "output#%process%#%pid%#%protocol%: %port%#=aa"

set "%port%=aa"

set/a totalPort+=1

)

exit/b

可以帮你检测出哪个进程开启了哪个端口查出来之后,直接写个批处理:

taskkill /im 那个进程的名字

以上就是关于【批处理】如何查看进程详细信息全部的内容,包括:【批处理】如何查看进程详细信息、windows下我有一个bat程序,当这个程序开启时,任务进程名是cmd.exe,怎么才能根据我的这个文件找出进程PI、bat命令检测进程存在等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10158825.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存