What errors? It's impossible for us to help if you don't post the exact error messages that you encountered.
Some context would be nice too. What's PlantsVsZombies.exe, what does/should it do? Why do you think people would have it on their computer (at all, and especially at a location included in PATH)?
Why am I certain that the file exists? Because I conducted the test by remotely controlling the user's device myself. In the same environment, when I removed the following code, the operation became normal. On the contrary, this problem occurred. I'm sure it's not a problem with the path. Whether it's an absolute path or a relative path, the same content will be prompted. (The key point is that the operation is normal after removing the following code.)
At present, this problem has been encountered in a small number of users' Win7 and Win10. The occurrence of this situation is relatively rare.
But I don't understand why the operation is normal after removing that part of the code. I used x86_64-pc-windows-msvc and i686-pc-windows-msvc for compilation, and the results were all the same.
could it be some anti-(virus|malware|etc.) running on target user's machine blocking app's access to target file?
(due to redirected in/out-puts in final compiled binary flagging it as a security threat?)
edit: typo