Skip to content

Instantly share code, notes, and snippets.

@wangye
Last active December 10, 2015 21:08
Show Gist options
  • Save wangye/4493232 to your computer and use it in GitHub Desktop.
Save wangye/4493232 to your computer and use it in GitHub Desktop.
REM
REM COPYRIGHT : Copyright (c) 2013 WangYe. All rights reserved.
REM
REM DESCRIPTION : Clear ALL FILES in Excel XLSTART directory.
REM AUTHOR : WANGYE
REM WEBSITE : http://wangye.org
REM
REM Compatible with Office 2003/2007/2010
REM
REM Last Update : 2013/1/10
REM
@ECHO OFF
:BEGIN
CLS
ECHO Copyright (c) 2013 WangYe. All rights reserved.
ECHO For more information please visit http://wangye.org
ECHO.
ECHO Please wait...
TASKKILL /F /IM EXCEL.EXE>NUL 1>NUL 2>NUL
SETLOCAL EnableDelayedExpansion
FOR /L %%i IN (14,-1,11) DO (
if %%i NEQ 13 (
SET KEY_NAME="HKLM\SOFTWARE\Microsoft\office\%%i.0\Excel\InstallRoot"
FOR /F "tokens=2*" %%A IN ('REG QUERY !KEY_NAME! /v "Path" 2^>NUL ^| FINDSTR "REG_SZ"') DO (
SET ExcelInstallDir=%%B
CALL :EMPTY_DIR "!ExcelInstallDir!\XLSTART">NUL
)
)
)
SET EXCELDIR=\Microsoft\Excel
CALL :EMPTY_DIR "%APPDATA%%EXCELDIR%\XLSTART">NUL
DEL /F /S /A /Q "%APPDATA%%EXCELDIR%">NUL 1>NUL 2>NUL
GOTO :SUCCEEDED
:EMPTY_DIR
ECHO %1
IF EXIST %1 (
DEL /F /S /A /Q %1>NUL 1>NUL 2>NUL
RMDIR /S /Q %1>NUL 1>NUL 2>NUL
)
MKDIR %1>NUL 1>NUL 2>NUL
GOTO :EOF
:SUCCEEDED
ECHO.
ECHO Microsoft Office Excel Recovery complete:-)
ECHO.
PAUSE
:EOF
EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment