I have a piece of software written in c++, that has to call command line and execute 2 simple commands. The problem is, they need to be executed in the main directory of my program (folder where exe file is). How can I make sure, that they will execute in this directory, if it can be different on PCs (for example "Program Files" or "Program Files(x86)").
Asked
Active
Viewed 69 times
-1
-
Posible dupliacte: [get-the-directory-that-a-program-is-running-from](http://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from) – Mara Black Aug 14 '16 at 19:16
1 Answers
0
On windows, you can use the GetModuleFileName WinAPI, which will return you the path of the exe that you can cd
to and execute your commands.

Mohamed Moanis
- 477
- 7
- 18