@echo off
if /i not exist %windir%\System32\spp\store\2.0\tokens~.dat goto -error

:-back
net stop sppsvc
if /i exist %windir%\System32\spp\tokens~ rd /s /q %windir%\System32\spp\tokens
ren %windir%\System32\spp\tokens~ tokens
if /i exist %windir%\SYSWOW64\spp\tokens~ rd /s /q %windir%\SYSWOW64\spp\tokens
ren %windir%\SYSWOW64\spp\tokens~ tokens
if /i exist %windir%\System32\spp\store\2.0\tokens~.dat del /f /q %windir%\System32\spp\store\2.0\tokens.dat
ren %windir%\System32\spp\store\2.0\tokens~.dat tokens.dat
if exist %windir%\System32\spp\store\2.0\cache\cache.dat del /f /q %windir%\System32\spp\store\2.0\cache\cache.dat
cscript.exe %Systemroot%\System32\slmgr.vbs //nologo -ipk MHF9N-XY6XB-WVXMC-BTDCT-MKKG7
if /i not %errorlevel%==0 goto -error
echo msgbox "Restore SPP-channel Windows 8.1 (build 6.3.9600) is complete." ^& vbNewLine  ^& vbNewLine ^& "Please restart your PC." > %windir%\restore.vbs
%windir%\restore.vbs
del /f /q %windir%\restore.vbs & del /f /q %windir%\SPP-restore.bat & exit

:-error
echo msgbox "Rollback to SPP-channel Windows 8.1 (build 6.3.9600) is failed." > %windir%\rollback.vbs
%windir%\rollback.vbs
del /f /q %windir%\rollback.vbs
