Clear-Host # DOWNLOADS GUID $FolderToRedirect = "{374DE290-123F-4565-9164-39C4925E467B}" # DOWNLOADS VARIABLES $FolderName = "Downloads" $LocalPath = "C:\Users\$env:username\$FolderName" $SharePath = "\\$env:computername\Users\$env:username\$FolderName" # CREATE DOWNLOADS FOLDER IF (!(TEST-PATH $LocalPath)) { New-Item "$LocalPath" -type directory -force } # CREATE SHARE OF DOWNLOADS FOLDER If (!(GET-WMIOBJECT Win32_Share -filter "name='$FolderName'")) { $Shares=[WMICLASS]"WIN32_Share" $Shares.Create("$LocalPath","$FolderName",0) } # REG KEYS $ShellFolder = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" $UserShellFolder = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" # REDIRECT TO SHARED PATH Set-ItemProperty -Path $UserShellFolder -Name "$FolderToRedirect" -Value "$SharePath" Set-ItemProperty -Path $ShellFolder -Name "$FolderToRedirect" -Value "$SharePath" # NOTES # OTHER FOLDER NAMES ARE LOCATED AT # HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders # HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
Notes
net share Downloads=C:\Users\%username%\Downloads /grant:everyone,FULL
REG DELETE “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders” /v {374DE290-123F-4565-9164-39C4925E467B} /f
REG DELETE “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders” /v {374DE290-123F-4565-9164-39C4925E467B} /f
REG ADD “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders” /v {374DE290-123F-4565-9164-39C4925E467B} /t REG_SZ /d \\%computername%\Users\%username%\Downloads
REG ADD “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders” /v {374DE290-123F-4565-9164-39C4925E467B} /t REG_SZ /d \\%computername%\Users\%username%\Downloads
————————–
Junctions
dir “%userprofile%” /AL
Downloads*{374DE290-123F-4565-9164-39C4925E467B}*%username%*Security*Downloads*\\%computername%\%username%\Downloads