Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 532
Martin Buberl Avatar asked Apr 12 '12 22:04

Martin Buberl


2 Answers

This is the shortest way:

$env:APPDATA 

or for local app data:

$env:LOCALAPPDATA 
like image 134
Dmytro Shevchenko Avatar answered Sep 29 '22 16:09

Dmytro Shevchenko


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') 
like image 26
Martin Buberl Avatar answered Sep 29 '22 15:09

Martin Buberl