We have user's My Documents folder remapping to a UNC path which is also the same path for their Home Directories which is mounted as a drive letter at login.
We are moving storage locations, and need to change the My Documents redirection path on the local machine from the \\SERVERNAME\SHARENAME to H:\
Using a GPO Folder Redirection policy does not work.
I want to find all user accounts in the HKU hive, including the default, and change the value, write a log file so the script can check to see if a computer has been fixed and exit. I also want to have it pop up a notification window during this process so the user knows they will be logged off when the script completes and they can then log in again.
I've been trying with regular batch files and with
IF EXIST C:\temp GOTO next
IF EXIST c:\temp\%USERNAME%.log GOTO end
echo %date% %time% > C:\temp\%USERNAME%.log
c:\windows\system32\reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal" /f >> c:\temp\%USERNAME%.log 2>&1
c:\windows\system32\reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Personal /t REG_SZ /d "H:\\" /f >> c:\temp\%USERNAME%.log 2>&1
and this one I found via google
REM Modify a registry key in for all logged in users
REM Also modify it in the .DEFAULT hive so future users get it.
REM Copyright Jared Barneck
REM %1 is the value of %a that is passed.
REG Add HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders /v Personal /t REG_SZ /d H:\\
REM Going to :end here only ends this instance of the call to the
REM :modkey label. It does not end the whole batch file.
FOR /F "tokens=2* delims=\" %%a IN ('REG QUERY HKU ^|Findstr /R "DEFAULT S-1-5-[0-9]*-[0-9-]*$"') DO CALL :modkey %%a
REM Going to :end here ends the whole batch file.