Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] - psutil does not report the correct path via Process.exe() if a mounted volume is in the path. #2180

Open
mratzenb opened this issue Nov 30, 2022 · 2 comments

Comments

@mratzenb
Copy link

Summary

  • OS: Windows Server 2019
  • Architecture: 64 Bit
  • Psutil version: 5.9.4
  • Python version: 3.11.0
  • Type: core

Description

psutil.Process.exe() is not reporting the correct path to a process.

The situation is the following: There are multiple processes running in C:\test\my-program\tomcat\bin\tomcat.exe. Moreover, there are multiple versions of my-program (e.g. my-program1.0, my-program1.1, ...). Additionally, test is a mounted volume and provides the following information:

 Directory of C:\
04/12/2022  07:04 PM    <DIR>               home
03/23/2022  01:50 PM    <JUNCTION>          test [\??\Volume{e4a9240d-9878-4c6c-8594-00fea2f7af11}\]
11/16/2022  02:02 PM    <DIR>               Program Files
04/12/2022  03:30 PM    <DIR>               Program Files (x86)
...

In my script, I am checking if processes of my-program are running. For that, I am interested in the PID and the location of the Process (psutil.Process.exe()). Gathering this information is done via psutil.process_iter(). The processes are listed correctly (PID). However, the problem is psutil.Process.exe().

When calling psutil.Process.exe() I would expect, that the returned path to the executable is C:\test\my-program1.0\tomcat\bin\tomcat.exe, which it is if test is not a mounted volume. However, if test is a mounted volume, it returns \my-program1.0\tomcat\bin\tomcat.exe. Meaning that the part C:\test is missing.

I guess this problem is somewhat related to #775, but might be slightly different.

Additional Info on the Mounted Volume

According to Windows, the drive is of Type Mounted Volume. However, the type switches to Local Disk if I look at the properties of the Volume. The File System inside the Volume is NTFS.

@lijm1206
Copy link

ImportError: DLL load failed while importing _psutil_windows: 找不到指定的模块。

@mratzenb
Copy link
Author

mratzenb commented Dec 5, 2024

Are there any updates on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants