@echo off
title ＝＝＝手动备份恢复office 2010 专业增强版＝＝＝
echo 恢复前，请确认密钥为原始安装激活成功的密钥，并且，硬件没有改动！
echo 如果不能确认请直接关闭本程序！
echo.

:begin
set "xxx="&set /p xxx=请选择（1.备份　2.还原）：
if "%xxx%" neq "1" if "%xxx%" neq "2" cls&goto begin
cls&goto xx%xxx%

:xx1
if NOT EXIST "%~dp0bakkey" md "%~dp0bakkey">nul 2>nul
copy /y "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\tokens.dat" "bakkey\tokens.dat"
copy /y "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\Cache\cache.dat" "bakkey\cache.dat"
echo.
echo.
set /p xy=请输入备份 Office2010 激活密钥（×××-×××格式，按回车确定）：
echo %xy%>%~dp0bakkey\key.txt
echo.
echo.
echo          备份完成！按任意键退出 ......
pause >nul
exit

:xx2
net stop "osppsvc"
copy /y "bakkey\tokens.dat" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\"
copy /y "bakkey\cache.dat" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\Cache\"
for /f "delims=," %%i in (%~dp0bakkey\key.txt) do cscript OSPP.VBS /inpkey:%%i
echo.
echo.
echo          恢复成功！按任意键退出 ......
pause >nul