在NodeJS中,我需要“访问”一个正在运行的VSCode示例,并查看当前工作目录是否是一个特定的文件夹,即“/home/foobar/Desktop/myproject”。这在NodeJS中可能吗?
g6baxovj1#
在Unix系统上,请参阅Find out current working directory of a running process?(pwdx <PID>和其他方法)。在Windows系统上,请参阅windows batch command to determine working directory of a process(安装执行此工作的非本机程序的建议)和Is it possible to determine the working directory of another process?(如何使用Windows API执行此操作,我不知道是否可以通过NodeJS直接访问)。至少在UNIX系统上,您可以使用child_process(另请参阅Execute a command line binary with Node.js)。
pwdx <PID>
child_process
1条答案
按热度按时间g6baxovj1#
在Unix系统上,请参阅Find out current working directory of a running process?(
pwdx <PID>
和其他方法)。在Windows系统上,请参阅windows batch command to determine working directory of a process(安装执行此工作的非本机程序的建议)和Is it possible to determine the working directory of another process?(如何使用Windows API执行此操作,我不知道是否可以通过NodeJS直接访问)。至少在UNIX系统上,您可以使用child_process
(另请参阅Execute a command line binary with Node.js)。