在PowerShell中获取%AppData%的路径


Answers:



9

要获取AppData目录,请使用以下GetFolderPath方法:

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

或就像安迪(Andy)在评论中提到的那样:

[Environment]::GetFolderPath('ApplicationData')

3
略短一些的版本:[Environment]::GetFolderPath('ApplicationData')
Andy Arismendi'4

这一切给我的是“ ApplicationData”,而不是路径。
Garr Godfrey 2015年

6
$TempInstallerPath="$Env:USERPROFILE\AppData\Local\Downloaded Installations"
if(Test-Path $TempInstallerPath)
{
    Remove-Item "$TempInstallerPath\*" -Recurse -Force -ErrorAction 0
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.