获取进程启动的工作目录

Get working directory the process was started with

Windows 和 Python。

是否可以在当前工作目录更改后获取启动进程(不受我控制)的工作目录?

我怀疑 Windows 会无可救药地丢失此信息,但正在寻求确认。

根据 eryksun 的规定:

Python adds the script directory to sys.path, not the working directory. The Windows ProcessParameters store the DosPath string and Handle for the working directory. All traces of the initial working directory are removed when a new working directory is set, i.e. the DosPath string is updated and the old directory Handle is closed and replaced by the new one. I checked whether auditing process creation might help, but the audit event doesn't store the initial working directory.