I need to get the full path(absolute) of Powershell.exe to run powershell scripts in my code . Can anyone suggest me any library or inbuilt method to do this .
I tried boost filesystem's absolute() method and getFUllPathName() method in windows.h . But all i manage to get is the current working directory of my project .
Alternatively (if you don't like to rely on environment variables) you can also query the registry. Powershell, on installation, writes a FriendlyTypeName value, which, on my machine is
@"%systemroot%\system32\windowspowershell\v1.0\powershell.exe", -107
which contains the path.
The registry key is HKEY_CLASSES_ROOT\Microsoft.PowerShellConsole.1\FriendlyTypeName
Use the Windows API to query the registry.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments