@echo off
TITLE Revert the removal of 'Library' folders.
COLOR 1F
mode con cols=95 lines=10
echo.

cd %systemroot%\system32
call :IsAdmin
CLS
TITLE Windows 10: Revert the removal of 'Library' folders.
cls
color 1f
echo.
ver | findstr /i " 10\.0\." > nul
IF "%ERRORLEVEL%" EQU "0" goto :Win10
echo This script only works on Windows 10 Kernels.
echo.
pause
exit

:Win10
echo.
echo Simple script to revert the removal of the 'Library' folders.
echo.

Reg add "HKCU\Software\Classes\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}" /v "System.IsPinnedToNameSpaceTree" /t REG_DWORD /d "1" /f >nul 2>&1
Reg add "HKLM\Software\Classes\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}" /v "System.IsPinnedToNameSpaceTree" /t REG_DWORD /d "1" /f >nul 2>&1

Reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{2B20DF75-1EDA-4039-8097-38798227D5B7}\PropertyBag" /v "ThisPCPolicy" /f >nul 2>&1
Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{2B20DF75-1EDA-4039-8097-38798227D5B7}\PropertyBag" /f >nul 2>&1

Reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{E25B5812-BE88-4bd9-94B0-29233477B6C3}\PropertyBag" /v "ThisPCPolicy" /f >nul 2>&1
Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{E25B5812-BE88-4bd9-94B0-29233477B6C3}\PropertyBag" /f >nul 2>&1

Reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{2B20DF75-1EDA-4039-8097-38798227D5B7}\PropertyBag" /v "ThisPCPolicy" /f >nul 2>&1
Reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{2B20DF75-1EDA-4039-8097-38798227D5B7}\PropertyBag" /f >nul 2>&1

Reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{E25B5812-BE88-4bd9-94B0-29233477B6C3}\PropertyBag" /v "ThisPCPolicy" /f >nul 2>&1
Reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{E25B5812-BE88-4bd9-94B0-29233477B6C3}\PropertyBag" /f >nul 2>&1

echo.
echo Done. 
echo.
echo Open 'ThisPC' and right click 'Libraries' and then 'Restore Default Libraries' line.
echo.

:Finished
pause
exit

:IsAdmin
Reg.exe query "HKU\S-1-5-19\Environment"
If Not %ERRORLEVEL% EQU 0 (
 Cls
 echo.
 Echo You must have administrator rights to continue...
 echo.
 Pause
 Exit
)
