@Echo Off
Title Revert SSD Tweaks
Color 1F
cd %systemroot%\system32
call :IsAdmin

for /f "tokens=4-5 delims=. " %%i in ('ver') do set "TestWinVer=%%i"
IF NOT DEFINED TestWinVer SET "TestWinVer=None"

echo Setting SuperFetch, PreFetcher, FastBoot {W10} and BootTrace to defaults...
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" /v "EnableSuperfetch" /t REG_DWORD /d "3" /f >NUL 2>&1
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" /v "EnablePrefetcher" /t REG_DWORD /d "3" /f >NUL 2>&1
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" /v "EnableBootTrace" /t REG_DWORD /d "0" /f >NUL 2>&1
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "DisablePagingExecutive" /t REG_DWORD /d "00000000" /f >NUL 2>&1

IF /I "%TestWinVer%"=="10" REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /v "HiberbootEnabled" /t REG_DWORD /d "1" /f >NUL 2>&1
schtasks /Change /TN "\Microsoft\Windows\Defrag\ScheduledDefrag" /ENABLE >NUL 2>&1 && ( Echo Scheduled Defrag/Trim Task: Enabled )

echo.
echo Done. Reboot is required to fully reset parameters.
echo.
echo Note that you may need to turn on 'WSearch' Indexing and 
echo 'Superfetch' services as these may be disabled.
echo.
pause
Exit

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