Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use powershell to call SHGetKnownFolderPath?

I'm a total noob on windows powershell. How can I use psl to call SHGetKnownFolderPath ? I want to then also call SHSetKnownFolderPath if I dont like some of the values back from Get call.

like image 721
Alan Jurgensen Avatar asked Jan 13 '23 08:01

Alan Jurgensen


1 Answers

You can use P/Invoke. Lee Holmes has an example of how to do this from PowerShell here. There's an example of how to use SHGetKnownFolderPoath here.

Alternatively, you might just be able to use Environment.GetFolderPath:

PS> [Environment]::GetFolderPath('CommonApplicationData')
C:\ProgramData

You can get the list of available options by the following:

PS> [Enum]::GetNames([Environment+SpecialFolder])
like image 95
Roger Lipscombe Avatar answered Jan 28 '23 05:01

Roger Lipscombe