windows batch command to determine working directory of a process

后端 未结 3 993
予麋鹿
予麋鹿 2020-12-16 17:12

Why I ask is that my program uses 3rd party software that sometimes leaves behind orphan processes that have no link back to my program or the 3rd party process. These orph

3条回答
  •  时光说笑
    2020-12-16 17:36

    tlist from WDK to the rescue! The 2nd line of its output ("CWD: ...") shows the working directory of a process:

    > tlist 944
     944 postgres.exe
       CWD:     D:\Lab\Database\pgsql\test\
       CmdLine: "D:/Tools/pgsql/bin/postgres.exe"  -D "."
       VirtualSize:   221116 KB   PeakVirtualSize:   242620 KB
       WorkingSetSize: 17076 KB   PeakWorkingSetSize: 19336 KB
       NumberOfThreads: 4
       9084 Win32StartAddr:0x00000000 LastErr:0x00000000 State:Waiting
       8504 Win32StartAddr:0x00000000 LastErr:0x000000b7 State:Waiting
       8616 Win32StartAddr:0x00000000 LastErr:0x00000000 State:Waiting
       7468 Win32StartAddr:0x00000000 LastErr:0x00000000 State:Waiting
        9.3.5.14202 shp  0x0000000000400000  D:\Tools\pgsql\bin\postgres.exe
     6.1.7601.18247 shp  0x00000000770D0000  C:\Windows\SYSTEM32\ntdll.dll
     ...
    

    See the doc for more info.

提交回复
热议问题