@echo off
PUSHD %~dp0
IF EXIST "%ProgramFiles(x86)%" (
   SET "SYSPath=%SystemRoot%\sysWOW64"
   SET "CommFile=%ProgramFiles(x86)%\Common Files\Microsoft Shared"
) ELSE (
   SET "SYSPath=%SystemRoot%\system32"
   SET "CommFile=%ProgramFiles%\Common Files\Microsoft Shared"
)
net stop osppsvc >nul 2>nul
sc delete osppsvc >nul 2>nul
taskkill /f /im ONENOTEM.EXE >nul 2>nul
del /f /q "%TEMP%\*.reg" >nul 2>nul
regedit /s "%~dp0data\unist.dat"
"%~dp0data\fr.exe" -frA2U8 "%~dp0data\unist.dat" "%temp%\unist.reg" "\WOW6432Node" ""
"%~dp0data\fr.exe" -frA2U8 "%temp%\unist.reg" "%temp%\unist.reg" "D:|Office2016" "%CD:\=|%"
regedit /s "%TEMP%\unist.reg"
REGSVR32 /u /s "%~dp0MShared\Portal\PortalConnectCore.dll"
REGSVR32 /u /s "%~dp0MShared\MSClientDataMgr\MSCDM.dll"
REGSVR32 /u /s "%~dp0MShared\Office16\MSOXEV.dll"
REGSVR32 /u /s "%~dp0MShared\Office16\msoshext.dll"
REGSVR32 /u /s "%CommFile%\VBA\VBA7.1\VBE7.dll"
REGSVR32 /u /s "%SYSPath%\FM20.DLL"
REGSVR32 /u /s "%~dp0Office16\Addins\OTKLOADR.dll"
REGSVR32 /u /s "%~dp0Office16\ACCWIZ.dll"
REGSVR32 /u /s "%~dp0Office16\CHART.DLL"
REGSVR32 /u /s "%~dp0Office16\IEAWSDC.dll"
REGSVR32 /u /s "%~dp0Office16\MSOEURO.dll"
REGSVR32 /u /s "%~dp0Office16\MSOHEV.dll"
REGSVR32 /u /s "%~dp0Office16\MSOHEVI.dll"
REGSVR32 /u /s "%~dp0Office16\MSRTEDIT.dll"
REGSVR32 /u /s "%~dp0Office16\REFEDIT.dll"
REGSVR32 /u /s "%~dp0Office16\NAME.dll"
REGSVR32 /u /s "%~dp0Office16\OSF.dll"
REGSVR32 /u /s "%~dp0Office16\MSADDNDR.dll"
del /f /q "%WinDir%\ShellNew\ACCESS.*"
del /f /q "%WinDir%\ShellNew\EXCEL.*"
del /f /q "%WinDir%\ShellNew\EXCEL12.*"
del /f /q "%WinDir%\ShellNew\PWRPNT.*"
rd /s /q "%APPDATA%\Microsoft\Access"
rd /s /q "%APPDATA%\Microsoft\PowerPoint"
rd /s /q "%APPDATA%\Microsoft\Office"
rd /s /q "%APPDATA%\Microsoft\Excel"
rd /s /q "%APPDATA%\Microsoft\Word"
rd /s /q "%APPDATA%\Microsoft\Templates"
rd /s /q "%APPDATA%\Microsoft\AddIns"
rd /s /q "%APPDATA%\Microsoft\Proof"
rd /s /q "%APPDATA%\Microsoft\CLView"
rd /s /q "%APPDATA%\Microsoft\UProof"
rd /s /q "%APPDATA%\Microsoft\Bibliography"
rd /s /q "%APPDATA%\Microsoft\QuickStyles"
rd /s /q "%APPDATA%\Microsoft\Spelling"
rd /s /q "%APPDATA%\Microsoft\Document Building Blocks"
rd /s /q "%UserProfile%\AppData\Local\Microsoft\Office"
rd /s /q "%AllUsersProfile%\Microsoft\Office"
rd /s /q "%CommonProgramFiles%\Microsoft Shared\OFFICE16"
rd /s /q "%ProgramFiles%\Microsoft.NET\Primary Interop Assemblies"
rd /s /q "%ProgramFiles(x86)%\Microsoft.NET\Primary Interop Assemblies"
rd /s /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Office 2016"
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\office2016" /f 
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\office2016" /f 
for /f "tokens=3" %%i in ('Reg Query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop" ') do (set "ppath=%%~i")
del /f /q "%ppath%\Word*.lnk"
del /f /q "%ppath%\excel*.lnk"
del /f /q "%ppath%\PowerPnt*.lnk"
del /f /q "%ppath%\Access*.lnk"
del /f /q "%USERPROFILE%\Desktop\Access*.lnk"
del /f /q "%USERPROFILE%\Desktop\excel*.lnk"
del /f /q "%USERPROFILE%\Desktop\PowerPnt*.lnk"
del /f /q "%USERPROFILE%\Desktop\Word*.lnk"
del /f /q "%~dp0Office16\sppc*.dll"
net localgroup administrators "Network Service" /del >nul 2>nul
regsvr32 /u /s "%CommonProgramFiles%\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPWMI.dll"
regsvr32 /u /s "%CommonProgramFiles(x86)%\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPWMI.dll"
takeown /f "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\tokens.dat"
icacls "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\tokens.dat" /grant administrators:F /t
rd /s /q "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform"
rd /s /q "%CommonProgramFiles%\Microsoft Shared\OfficeSoftwareProtectionPlatform"
rd /s /q "%CommonProgramFiles(x86)%\Microsoft Shared\OfficeSoftwareProtectionPlatform"
assoc .=.file >nul
