19 March, 2010
0 Comments
1 category
If you want to use the systems “%PROGRAMFILES%” folder in PowerShell, use:
$rootInstallationFolder = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFiles)
$rootInstallationFolder
Result
C:\Program Files (x86)
Note
Because SpecialFolders is a nested type in System.Environment, you must use the “+” sign and not a “.”, else you get the error:
Unable to find type [System.Environment.SpecialFolder]: make sure that the assembly containing this type is loaded.
Tags: PowerShell
Category: Uncategorized
Nope got back
PS C:\Windows\system32> $rootfolder=[system.environment]::getfolderpath([System.Environment+specialfolder]::ProgramFiles)
$rootfolder
C:\Program Files