Getting the path of %AppData% in PowerShell

How can I get the path for the application data directory (e.g. C:\Users\User\AppData\Roaming) in PowerShell?

Answers


This is the shortest way:

$env:APPDATA

or for local app data:

$env:LOCALAPPDATA

To get the AppData directory, use the GetFolderPath method:

[Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)

Or as Andy mentions in his comment, simply:

[Environment]::GetFolderPath('ApplicationData')

$TempInstallerPath="$Env:USERPROFILE\AppData\Local\Downloaded Installations"
if(Test-Path $TempInstallerPath)
{
    Remove-Item "$TempInstallerPath\*" -Recurse -Force -ErrorAction 0
}

Need Your Help

How to get human-readable type of a complex expression at compilation time?

c++ gcc types

Suppose there's a complex expression EXPRESSION, and it's quite hard even for the IDE to find some of the methods called in it etc., so it's very hard to figure out the type it evaluates to. Curren...