@echo off
title WPS文字2012 安装/卸载 By www.pc6.com
color 8F
mode con: cols=54 lines=12
echo.
echo   即将安装/卸载 WPS文字2012
echo.
echo   1.首次运行，请先选择安装
echo.
echo   2.选择卸载后，删除整个目录，即可完成卸载
echo.
echo. ===================================================
pause
cls
echo.
echo  1 (安装 WPS文字2012)   2 (卸载 WPS文字2012)
echo.
echo  3 (创建新建项目中WPS文字2012自有格式)
echo.
echo  4 (删除新建项目中WPS文字2012自有格式)
echo.
echo. ===================================================
echo.
SET /P ST= 请选择：
echo. 
if /I "%ST%"=="1" goto in
if /I "%ST%"=="2" goto un
if /I "%ST%"=="3" goto innew
if /I "%ST%"=="4" goto unnew1
echo  无效选择，按任意键退出！
pause >nul
exit

:in
cd office6
ksomisc.exe -regoledefhndlr
ksomisc.exe -reg_kso
ksomisc.exe -reg_wps
ksomisc.exe -reg_kde
ksomisc.exe -regksee
ksomisc.exe -rename 2052 install
ksomisc.exe -assoword
ksomisc.exe -savetomso
ksomisc.exe -rebuildicon
ksomisc.exe -createlink startmenu 2052 "WPS文字2012"
ksomisc.exe -createlink desktop 2052
reg add "HKEY_CLASSES_ROOT\.doc\WPS.Doc.6\ShellNew" /v "FileName" /d "%cd%\2052\newfile.wps" /f>nul 2>nul
reg add "HKEY_CURRENT_USER\Software\Kingsoft\Office\6.0\wps" /v "uifile" /d "res/wpsrainbow.kui" /f>nul 2>nul
if exist "%ProgramData%" (xcopy /e /q /h /r /y /d /I "%cd%\2052\buildins" "%ProgramData%\kingsoft\Office6\buildins" >nul) else (xcopy /e /q /h /r /y /d /I "%cd%\2052\buildins" "%AllUsersProfile%\Application Data\kingsoft\Office6\buildins" >nul)
if exist "%ProgramData%" (xcopy /e /q /h /r /y /d /I "%cd%\2052\license2.dat" "%ProgramData%\kingsoft\Office6" >nul) else (xcopy /e /q /h /r /y /d /I "%cd%\2052\license2.dat" "%AllUsersProfile%\Application Data\kingsoft\Office6" >nul)
cls
echo.
echo  是否创建新建项目中WPS文字2012自有格式？
echo.
echo. ===================================================
echo.
echo  1 (是)                  2 (否) 
echo.
echo. ===================================================
echo.
SET /P ST= 请选择：
echo. 
if /I "%ST%"=="1" goto inok
if /I "%ST%"=="2" goto unnew
echo  无效选择，按任意键退出！
pause >nul
exit

:inok
cls
echo.
echo  安装成功，按任意键退出！
echo.
pause >nul
exit

:un
cd office6
ksomisc.exe -deletelink desktop 2052
ksomisc.exe -deletelink startmenu 2052 "WPS文字2012"
ksomisc.exe -rename 2052 uninstall
ksomisc.exe -unreg_wps
ksomisc.exe -unassoword
ksomisc.exe -unregksee
ksomisc.exe -unreg_kso
ksomisc.exe -unreg_kde
ksomisc.exe -unregoledefhndlr
ksomisc.exe -rebuildicon
for /f "tokens=*" %%a in ('REG QUERY "HKEY_USERS" /s /v USERNAME ^| find /i "Volatile Environment"') do (
    for /f "tokens=*" %%1 in ('REG QUERY "%%a" /v USERNAME ^| find /i "%username%"') do (
    ::echo %%1
    SET "SID=%%a"
    )
)
for /f "tokens=1-4,* delims=\" %%i in ('echo %SID%') do (
SET "SID=%%j"
)
reg delete "HKEY_USERS\%SID%\Software\Kingsoft\Office" /f>nul 2>nul
cls
echo.
echo  是否删除个人配置文件？
echo.
echo. ===================================================
echo.
echo  1 (是)                  2 (否) 
echo.
echo. ===================================================
echo.
SET /P ST= 请选择：
echo. 
if /I "%ST%"=="1" goto del
if /I "%ST%"=="2" goto unok
echo  无效选择，按任意键退出！
pause >nul
exit

:innew
cd office6
ksomisc.exe -reg_wps
cls
echo.
echo  创建成功，按任意键退出！
echo.
pause >nul
exit

:unnew
reg delete "HKEY_CLASSES_ROOT\.wps\WPS.Document.6\ShellNew" /f>nul 2>nul
goto inok

:unnew1
reg delete "HKEY_CLASSES_ROOT\.wps\WPS.Document.6\ShellNew" /f>nul 2>nul
cls
echo.
echo  删除成功，按任意键退出！
echo.
pause >nul
exit

:del
rd /S /Q  %AppData%\kingsoft\office6
goto unok

:unok
cls
echo.
echo  卸载成功，按任意键退出！
echo.
pause >nul
exit