Windows 上的 GNU Make 看不到某些可执行文件

GNU Make on Windows cannot see some executables

我的部分部署是 运行 Windows 上 Makefile 上称为“部署”的目标 运行,除其他外,taskkill.exepsexec.exe。两者都在 %PATH%.

中的 c:\windows\system32

当我尝试创建该目标时,我收到一条消息,提示无法找到 psexec。 Taskkill 按预期工作。

作为测试,我尝试简单地 dir c:\windows\system32\psexec.exe,但是从 makefile 中,我得到了“找不到文件”。然而,在相同的 shell 中,我可以 运行 相同的 dir 命令并获得肯定的响应。

为什么连文件的存在都看不到,更不用说运行了?

这里是一个示例 Makefile 目标:

exetest:
    @echo ------------------------------
    -dir /b c:\Windows\System32\PsExec.exe
    @echo ------------------------------
    -dir /b c:\Windows\System32\taskkill.exe

这就是命令提示符中发生的情况:

C:\Users\Owner\Documents\GitHub>make exetest
------------------------------
dir /b c:\Windows\System32\PsExec.exe
File Not Found
make: [exetest] Error 1 (ignored)
------------------------------
dir /b c:\Windows\System32\taskkill.exe
taskkill.exe

C:\Users\Owner\Documents\GitHub>dir /b c:\Windows\System32\PsExec.exe
PsExec.exe

C:\Users\Owner\Documents\GitHub>dir /b c:\Windows\System32\taskkill.exe
taskkill.exe

我正在 运行宁 GNU Make 3.81 和 Windows 7.

我已经尝试了 psexecpsexec64 - 两者的行为相同。

这里的问题是make,不是psexecpsexec64

所有 32 位进程都放在 file system redirector 下。

whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64

看来您使用的是 32 位 make 程序。因此它不会在 %windir%\System32 中看到 PsExec.exe。如果您 运行 32 位 shell 和 %windir%\SysWOW64\cmd.exe,行为是相同的,在这种情况下 dir /b c:\Windows\System32\PsExec.exe 会给您一个找不到文件的错误

您必须将路径修改为%windir%\Sysnative\PsExec.exe