![](https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
Find out a process name?
i.e. Can a process name be found from its ID?
![Find out a process name?: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
DetectHiddenWindows on IfWinExist ahk_pid %ThePID% { WinGet, ProcessName, ProcessName ; Uses the window found above. MsgBox %ProcessName% }
![Find out a process name?: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
DetectHiddenWindows on Run, Notepad.exe ,,,ThePID WinWait, Untitled - Notepad IfWinExist ahk_pid %ThePID% { WinGet, ProcessName, ProcessName ; Uses the window found above. MsgBox %ProcessName% }
![Find out a process name?: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![Find out a process name?: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![Find out a process name?: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
For managing processes Windows API provide two different libraries are present:
PSAPI.DLL functions (in psapi.dll) - avail in Windows NT and 2k/XP
ToolHelp functions (in kernel32.dll) - avail in Windows 9x/ME/2k/XP
As you can see, if you want to support Windows 9x then you must code using ToolHelp API and if you want to support WinNT then you have to code using PSAPI. Also note that these different libraries use different data structures to present and to manage processes.
PSAPI does not have one function that help us build one data structure to fit our needs. That is why I will use the following PSAPI functions in addition:
GetModuleFileNameEx() - given a process handle and a module base it will return us its full path.
typedef struct tagPROCESSENTRY32 { DWORD dwSize; DWORD cntUsage; DWORD th32ProcessID; ULONG_PTR th32DefaultHeapID; DWORD th32ModuleID; DWORD cntThreads; DWORD th32ParentProcessID; LONG pcPriClassBase; DWORD dwFlags; TCHAR szExeFile[MAX_PATH]; } PROCESSENTRY32, *PPROCESSENTRY32;
![Find out a process name?: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
I will try to apply this method to provide a get-full-path-of-process feature, even if there is no way easy way to support the same on Windows 9x.
![Find out a process name?: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![Find out a process name?: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![:D](http://www.autohotkey.com/board/public/style_emoticons/default/grin.png)
FULLPATH: WinGet,window,Id,A WinGet,file,ProcessName,ahk_id %window% Loop,HKEY_CURRENT_USER,Software\Microsoft\Windows\ShellNoRoam\MUICache,0,0 { IfInString,A_LoopRegName,%file% { RegRead,info path=%A_LoopRegName% Break } } MsgBox,%path% Return
![Find out a process name?: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Cool 8) Thanks
You can find the full path of a process by reading the registry.
![:D](http://www.autohotkey.com/board/public/style_emoticons/default/grin.png)
![Find out a process name?: post #10](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![:(](http://www.autohotkey.com/board/public/style_emoticons/default/sad.png)
![Find out a process name?: post #11](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![Find out a process name?: post #12](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![:(](http://www.autohotkey.com/board/public/style_emoticons/default/sad.png)
Skrommel
![Find out a process name?: post #13](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
I have Win2000, but from my understanding of the posted script, if you have two different programs which are named the same, in their own program folders, and you have both running at the same time, the script will return the same path for both programs.You can find the full path of a process by reading the registry.
When the full-path feature is implemented in Ahk, it should be able to identify which programs are running, even if many are identically named. This will be especially useful, for example, in scripts written for security purposes.
![Find out a process name?: post #14](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
2) Intuitive. Logical. Versatile. Adaptable. <
You can find the full path of a process by reading the registry.
FULLPATH: WinGet,window,Id,A WinGet,file,ProcessName,ahk_id %window% Loop,HKEY_CURRENT_USER,Software\Microsoft\Windows\ShellNoRoam\MUICache,0,0 { IfInString,A_LoopRegName,%file% { RegRead,info path=%A_LoopRegName% Break } } MsgBox,%path% Return
1) I couldn't find an answer through google, so:
Does anyone know how, in the following registry entry under that MUICache key (as an example only, there are lots of others) the number at the end is related to the icon within the dll?:
@C:\WINDOWS\system32\SHELL32.dll,-32517
(Which is for the "Taskbar and Start Menu" settings icon - most other Windows-related windows are also referenced this way).
This ",-32517" seems to somehow correspond to icon number 40 within SHELL32.dll. Any ideas what the relationship is? (Browsing to the MUICache key you can see plenty of others.)
2) Did the requested "get-full-path-of-process feature" make it onto the planned features list? I couldn't spot it myself.
![Find out a process name?: post #15](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)