manianis manianis - 9 days ago 4x
Bash Question

find the location of the cmd.exe file

I have built a c++ program that depends on "cmd.exe" to execute some of the tasks.
For now I and for test purposes the path to that file is "c:\windows\system32\cmd.exe".
My question is there any c++ API that returns the path of that file knowing that my program must work on win32 and on win64.


The interpreter path is available in the %COMSPEC% environment variable which can be read with GetEnvironmentVariable().