How can I get the physical path to an item if I know path of the .exe file?
Example:
$path = (Get-WmiObject -query "SELECT PathName FROM Win32_Service WHERE Name = 'Name of Service'").PathName
cd $path #and this command not work because $path return path with service name
UPDATE: Removes all characters after the file extension and trims double quotes if it finds any:
Get the directory of the file with the Split-Path cmdlet
The Parent parameter is the default split location parameter so you can leave it out: