In PowerShell, you can use the Shell.Application COM object to get the real path of the Downloads folder, regardless of its location. Here is a simple example: $downloadsPath = (New-Object -ComObject Shell.Application).Namespace('shell:Downloads').Self.Path
How to Correctly Find the Downloads Folder in PowerShell?
There are a number of posts on the web effectively saying to concatenate %UserProfile% and "Downloads" in order to find the path to the Downloads special folder. That is just wrong because a) "Downloads" is not localized, and b) because the user is able to change the location of the target folder (which I have done). One of The Scripting Guys posts says to use [environment]::getfolderpath() all to fetch special folders.[1] But, I have not found a documented list of valid strings to pass to that function and "downloads" is definitely not allowed.[2] Until .Net decides to fix [environment]::getfolderpath(), it looks like the only way to reliably find the path to the user's special Downloads folder is to do a bunch of really gross Win SDK calls. (See the CExplorerBrowserHostDialog::_FillViewWithKnownFolders() example in the Win7Samples up on GitHub.[3]) 🤮🤮🤮 Does anyone know if there is an easier way to do this? [1]: https://devblogs.microsoft.com/scripting/the-easy-way-to-use-powershell-to-work-with-special-folders/ [2]: https://github.com/dotnet/runtime/issues/554 [3]: https://github.com/microsoft/Windows-classic-samples/blob/1d363ff4bd17d8e20415b92e2ee989d615cc0d91/Samples/Win7Samples/winui/shell/appplatform/ExplorerBrowserCustomContents/ExplorerBrowserCustomContents.cpp