Active2 years, 11 months ago
This shows you the entire path to the executable file, and the name of the file itself. For this example, we see C:Program FilesMozilla Firefoxfirefox.exe. Now look at the very last part of that text and you’ll see firefox.exe – that’s the executable file. Everything before that. Mar 18, 2016 The old way to find the executable is to right-click on the icon that opens the app, then. How do I locate the.exe for Win 10 apps? I have an application that allows editing with another app. The old way to find the executable is to right-click on the icon that opens the app, then properties. Right click and open file location.
This question already has an answer here:
To find the location of Excel.Exe. Right click on Windows Task Bar Start Task Manager Processes tab (Task Manager can also be opened by pressing CTRL+SHIFT+ESC) 3. Locate Excel.Exe Right Click Open File Location to reach to Excel.Exe. Tips & Tricks 147 - Find the Location of Excel.Exe Generally Excel.Exe will be located in C:Program Files (x86)Microsoft OfficeOffice15 in case of Excel 2013 / Windows 7. During installation, if another path is chosen, Excel.Exe's location changes. What is an EXE file? Files ending with.EXE are executable program files. You should be able to run them by double-clicking them. If this does not work, the file may be damaged or something on your PC is blocking the execution - that could be your anti-virus software, or perhaps even a virus. Antique singer sewing machines serial numbers.
- Finding current executable's path without /proc/self/exe 12 answers
Is there a way in C/C++ to find the location (full path) of the current executed program?
(The problem with
Peter Mortensenargv[0]
is that it does not give the full path.)14.5k1919 gold badges8989 silver badges118118 bronze badges
eran![Location Location](/uploads/1/3/4/1/134121149/442567677.png)
3,98433 gold badges2626 silver badges4242 bronze badges
marked as duplicate by Jonathan Leffler cAug 17 '15 at 15:18
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
9 Answers
To summarize:
- On Unixes with
/proc
really straight and realiable way is to:readlink('/proc/self/exe', buf, bufsize)
(Linux)readlink('/proc/curproc/file', buf, bufsize)
(FreeBSD)readlink('/proc/self/path/a.out', buf, bufsize)
(Solaris)
- On Unixes without
/proc
(i.e. if above fails):- If argv[0] starts with '/' (absolute path) this is the path.
- Otherwise if argv[0] contains '/' (relative path) append it to cwd(assuming it hasn't been changed yet).
- Otherwise search directories in
$PATH
for executableargv[0]
.
Antares vending machine. Afterwards it may be reasonable to check whether the executable isn't actually a symlink.If it is resolve it relative to the symlink directory.This step is not necessary in /proc method (at least for Linux).There the proc symlink points directly to executable.Note that it is up to the calling process to setargv[0]
correctly.It is right most of the times however there are occasions when the calling process cannot be trusted (ex. setuid executable). - On Windows: use
GetModuleFileName(NULL, buf, bufsize)
3,68711 gold badge1818 silver badges2929 bronze badges
Use GetModuleFileName() function if you are using Windows.
aJ.25.2k2020 gold badges7373 silver badges118118 bronze badges
Shino C GShino C G
Please note that the following comments are unix-only.
The pedantic answer to this question is that there is no general way to answer this question correctly in all cases. As you've discovered, argv[0] can be set to anything at all by the parent process, and so need have no relation whatsoever to the actual name of the program or its location in the file system.
However, the following heuristic often works:
- If argv[0] is an absolute path, assume this is the full path to the executable.
- If argv[0] is a relative path, ie, it contains a
/
, determine the current working directory with getcwd() and then append argv[0] to it. - If argv[0] is a plain word, search $PATH looking for argv[0], and append argv[0] to whatever directory you find it in.
Note that all of these can be circumvented by the process which invoked the program in question. Finally, you can use linux-specific techniques, such as mentioned by emg-2. There are probably equivalent techniques on other operating systems.
Even supposing that the steps above give you a valid path name, you still might not have the path name you actually want (since I suspect that what you actually want to do is find a configuration file somewhere). The presence of hard links means that you can have the following situation:
Now, the approach above (including, I suspect, /proc/$pid/exe) will give
/some/where/else/foo
as the real path to the program. And, in fact, it is a real path to the program, just not the one you wanted. Note that this problem doesn't occur with symbolic links which are much more common in practice than hard links.In spite of the fact that this approach is in principle unreliable, it works well enough in practice for most purposes.
Dale HagglundDale Hagglund13.8k33 gold badges2323 silver badges3737 bronze badges
Not an answer actually, but just a note to keep in mind.
As we could see, the problem of finding the location of running executable is quite tricky and platform-specific in Linux and Unix. One should think twice before doing that.
If you need your executable location for discovering some configuration or resource files, maybe you should follow the Unix way of placing files in the system: put configs to
MichaelMichael/etc
or /usr/local/etc
or in current user home directory, and /usr/share
is a good place to put your resource files.67311 gold badge77 silver badges1515 bronze badges
In many POSIX systems you could check a simlink located under /proc/PID/exe. Few examples:
MestreLion7,52922 gold badges4343 silver badges4646 bronze badges
anon
Remember that on Unix systems the binary may have been removed since it was started. It's perfectly legal and safe on Unix. Last I checked Windows will not allow you to remove a running binary.
/proc/self/exe will still be readable, but it will not be a working symlink really. It will be.. odd.
Peter Mortensen14.5k1919 gold badges8989 silver badges118118 bronze badges
ThomasThomas2,62922 gold badges2323 silver badges2929 bronze badges
For Linux you can find the
GrumbelGrumbel/proc/self/exe
way of doing things bundled up in a nice library called binreloc, you can find the library at:3,52655 gold badges3030 silver badges3939 bronze badges
On Mac OS X, use
_NSGetExecutablePath
.See
man 3 dyld
and this answer to a similar question.Community♦
Tim RuddickTim Ruddick
I would
1) Use the basename() function: http://linux.die.net/man/3/basename
2) chdir() to that directory
3) Use getpwd() to get the current directory
2) chdir() to that directory
3) Use getpwd() to get the current directory
That way you'll get the directory in a neat, full form, instead of ./ or ./bin/.
Maybe you'll want to save and restore the current directory, if that is important for your program.
JCCyCJCCyC6,7221111 gold badges3737 silver badges7171 bronze badges
Not the answer you're looking for? Browse other questions tagged c++clinuxunixpath or ask your own question.
Active1 month ago
I just installed it but I don't know where it is. Can anyone help me? I've looked in a lot of places but I still don't know.
mrdannomrdanno
3 Answers
Look for
devenv.exe
, it should be at:Visual Studio Community 2015 Ne yo mad mp3 song free download.
Visual Studio Community 2017 Download free song ekadantaya vakratundaya.
Visual Studio Professional 2017
EricEric2,77733 gold badges3232 silver badges5252 bronze badges
For VS2019 it's now at:
C:Program Files (x86)Microsoft Visual Studio2019CommunityCommon7IDEdevenv.exe
12.9k66 gold badges8585 silver badges103103 bronze badges
.exe Executable File
I would say instead of looking at a predefined location for the installation which might change in future what you should do is as follows -
- Search for visual studio in apps search
- Right click and select 'Open file location'
- Once you have this shortcut, Right click on it and select and open properties and see the target field. This is your executable path.
For me it is -
Aniket ThakurAniket ThakurView Executable File
46k2828 gold badges211211 silver badges228228 bronze badges