ProcessGetName / ProcessGetPath

Returns the name or path of the specified process.

Name := ProcessGetName(PIDOrName)
Path := ProcessGetPath(PIDOrName)

Parameters

PIDOrName

Type: Integer or String

If omitted, the script's own process is used. Otherwise, specify either a number (the PID) or a process name:

PID: The Process ID, which is a number that uniquely identifies one specific process (this number is valid only during the lifetime of that process). The PID of a newly launched process can be determined via the Run function. Similarly, the PID of a window can be determined with WinGetPID. ProcessExist can also be used to discover a PID.

Name: The name of a process is usually the same as its executable (without path), e.g. notepad.exe or winword.exe. Since a name might match multiple running processes, only the first process will be operated upon. The name is not case-sensitive.

Return Value

Type: String

ProcessGetName returns the name of the specified process. For example: notepad.exe.

ProcessGetPath returns the path of the specified process. For example: C:\Windows\notepad.exe.

Error Handling

A TargetError is thrown if the process could not be found.

An OSError is thrown if the name/path could not be retrieved.

Process functions, Run, WinGetProcessName, WinGetProcessPath

Examples

Get the name and path of a process used to open a document.

Run "license.rtf",,, &pid  ; This is likely to exist in C:\Windows\System32.
try {
    name := ProcessGetName(pid)
    path := ProcessGetPath(pid)
}
MsgBox "Name: " (name ?? "could not be retrieved") "`n"
    .  "Path: " (path ?? "could not be retrieved")