I sometimes need to run a program from cmd.exe. This only seems to work if this program is present in C:\WINDOWS\system32.
So I just copied the .exe file into this folder and until now that worked (for Python and one or two other applications). However, I think this is not the proper way to do it. And when I try this with php.exe, I get an error saying some .dll was not found. I suspect it has to do with relative paths.
Could anyone please point out the correct way to do this?
Depending on your Windows version, you have to find the “Environment Variable” button (in Windows 7 is on “Advanced System Settings” inside “Properties” from “My Computer” context menu); in the “System variables” there should be a variable named
PATH. You can edit it and add the paths you want to include separated by;. Then reboot and it should work.In this way you include those paths in the set of directories where
cmd.exesearch for commands. In your example, the problem is thatphp.exeis found (since you copied it inSystem32which is in thePATH), but the.dllfiles are still on the php’s installation dir, so you need either to run your program from that directory or to update yourPATHincluding it.