@ECHO OFF

:START
TITLE Alumi Icon Pack 7600 X86 Un-Installer
CLS
ECHO.
ECHO.###########################################################
ECHO.##         Alumi Icon Pack 7600 X86 Un-installer         ##
ECHO.##                                                       ##
ECHO.##   DISABLE USER ACCOUNT CONTROL BEFORE PRESSING '1'!!  ##
ECHO.##                                                       ##
ECHO.##   Please also close all programs before proceeding.   ##
ECHO.##                                                       ##
ECHO.##                                                       ##
ECHO.##                                                       ##
ECHO.###########################################################
ECHO.
ECHO.
ECHO.Are you sure you want to remove Alumi Icon Pack 7600 X86?
ECHO.
ECHO.----------- 
ECHO.1. Yes.
ECHO.2. No.
ECHO.----------- 
set /p userinp=Please choose a number(1-2):
set userinp=%userinp:~0,1%
if "%userinp%"=="1" goto 1
if "%userinp%"=="2" goto 2
echo invalid choice
goto start
:1
GOTO INSTALLSCRIPTBEGIN
:2
GOTO EXITUNINSTALL


:INSTALLSCRIPTBEGIN
SET PATH1=%windir%\system32
SET PATH2=%windir%\SysWOW64
SET FILE1=imageres.dll
SET FILE2=shell32.dll
SET FILE3=imagesp1.dll

SET FILE98=*.db
SET PATH98=%SYSTEMDRIVE%\Users\%USERNAME%\AppData\Local\Microsoft\Windows\Explorer\
SET FILE99=IconCache.db
SET PATH99=%SYSTEMDRIVE%\Users\%USERNAME%\AppData\Local

if not exist "%PATH1%\%FILE2%.bak" GOTO NOINSTALLFOUND

:PERMISSIONCHK
	ATTRIB %windir%\system32 -h | FINDSTR /I "denied" >nul
	IF NOT ERRORLEVEL 1 (
		ECHO.
		ECHO.This script must be ran as an Administrator and with 
		ECHO.'User Account Control' completely disabled!!
		ECHO.
		ECHO.
		GOTO END
	)

	CLS
	IF /I EXIST %systemroot%\SysWOW64 SET BIT=Y

:DETECTARGUMENTS
	REM SET VAR1=1
	REM IF /I *%1 == *VAR SET VAR1=0

:SETSOURCEFOLDER
	REM Return the folder this batch file was launched from since the current
	REM directory will change if launched from a network share
	SET SOURCEFOLDER=%~dp0

:TAKEOWNERSHIP
	ECHO Taking ownership of %PATH1%\%FILE1%
	takeown /a /f %PATH1%\%FILE1%
	ECHO Granting Admin rights
	ICACLS %PATH1%\%FILE1% /Grant Administrators:F
	
	ECHO Taking ownership of %PATH1%\%FILE2%
	takeown /a /f %PATH1%\%FILE2%
	ECHO Granting Admin rights
	ICACLS %PATH1%\%FILE2% /Grant Administrators:F

	ECHO Taking ownership of %PATH1%\%FILE3%
	takeown /a /f %PATH1%\%FILE3%
	ECHO Granting Admin rights
	ICACLS %PATH1%\%FILE3% /Grant Administrators:F

        REM - Try to set permissions for caches to hopefully enable deletion...
	ECHO Taking ownership of %PATH98%\%FILE98%
	takeown /a /f %PATH98%\%FILE98%
	ECHO Granting Admin rights
	ICACLS %PATH98%\%FILE98% /Grant Administrators:F

	ECHO Taking ownership of %PATH99%\%FILE99%
	takeown /a /f %PATH99%\%FILE99%
	ECHO Granting Admin rights
	ICACLS %PATH99%\%FILE99% /Grant Administrators:F

     IF '%BIT%'=='Y' (
	ECHO Taking ownership of %PATH2%\%FILE1%
	takeown /a /f %PATH2%\%FILE1%
	ECHO Granting Admin rights
	ICACLS %PATH2%\%FILE1% /Grant Administrators:F

	ECHO Taking ownership of %PATH2%\%FILE2%
	takeown /a /f %PATH2%\%FILE2%
	ECHO Granting Admin rights
	ICACLS %PATH2%\%FILE2% /Grant Administrators:F

	ECHO Taking ownership of %PATH2%\%FILE3%
	takeown /a /f %PATH2%\%FILE3%
	ECHO Granting Admin rights
	ICACLS %PATH2%\%FILE3% /Grant Administrators:F
     ) ELSE (GOTO SKIP64ONWERSHIP)

:SKIP64ONWERSHIP

:STOPPROTECTIONSERVICE
        CLS
	ECHO Stopping Software Protection Services
	NET stop "Software Protection" /y

:COPYFILES

	REM - End Apps & Services that MAY be using shell32.dll....
	cd\
	taskkill /f /IM explorer.exe
	taskkill /f /IM nvvsvc.exe
	taskkill /f /IM WLIDSVCM.EXE
	taskkill /f /IM dllhost.exe

	ECHO Restoring "%PATH1%\%FILE1%.bak" to "%PATH1%\%FILE1%"
        ren "%PATH1%\%FILE1%" "imageres.OLD"
	COPY /Y "%PATH1%\%FILE1%.bak" "%PATH1%\%FILE1%"

	ECHO Restoring "%PATH1%\%FILE2%.bak" to "%PATH1%\%FILE2%"
        ren "%PATH1%\%FILE2%" "shell32.OLD"
	COPY /Y "%PATH1%\%FILE2%.bak" "%PATH1%\%FILE2%"

	ECHO Restoring "%PATH1%\%FILE3%.bak" to "%PATH1%\%FILE3%"
        ren "%PATH1%\%FILE3%" "imagesp1.OLD"
	COPY /Y "%PATH1%\%FILE3%.bak" "%PATH1%\%FILE3%"

     IF '%BIT%'=='Y' (
	ECHO Restoring "%PATH2%\%FILE1%.bak" to "%PATH2%\%FILE1%"
        ren "%PATH2%\%FILE1%" "imageres.OLD"
	COPY /Y "%PATH2%\%FILE1%.bak" "%PATH2%\%FILE1%"

	ECHO Restoring "%PATH2%\%FILE2%.bak" to "%PATH2%\%FILE2%"
        ren "%PATH2%\%FILE2%" "shell32.OLD"
	COPY /Y "%PATH2%\%FILE2%.bak" "%PATH2%\%FILE2%"

	ECHO Restoring "%PATH2%\%FILE3%.bak" to "%PATH2%\%FILE3%"
        ren "%PATH2%\%FILE3%" "imagesp1.OLD"
	COPY /Y "%PATH2%\%FILE3%.bak" "%PATH2%\%FILE3%"
     ) ELSE (GOTO SKIP64COPY)

        REM - Delete the IconCache.db and thumbnail caches...
        attrib -H "%PATH99%\%FILE99%"
	del "%PATH99%\%FILE99%"
        attrib -H "%PATH98%\%FILE98%"
	del "%PATH98%\%FILE98%"

CLS
REM - Write a cmd file to the temp folder for use with the above RunOnce...
if exist "%TEMP%\cleanuns.cmd" DEL %TEMP%\cleanuns.cmd
>>%TEMP%.\cleanuns.cmd ECHO.@ECHO OFF
>>%TEMP%.\cleanuns.cmd ECHO.:CLEANUPSCRIPTBEGIN
>>%TEMP%.\cleanuns.cmd ECHO.TITLE Alumi Icon Pack 7600 X86 Installer - Clean-Up...
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.SET FILE98=*.db
>>%TEMP%.\cleanuns.cmd ECHO.SET PATH98=%SYSTEMDRIVE%\Users\%USERNAME%\AppData\Local\Microsoft\Windows\Explorer\
>>%TEMP%.\cleanuns.cmd ECHO.SET FILE99=IconCache.db
>>%TEMP%.\cleanuns.cmd ECHO.SET PATH99=%%SYSTEMDRIVE%%\Users\%%USERNAME%%\AppData\Local
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.:START
>>%TEMP%.\cleanuns.cmd ECHO.	IF /I EXIST %%systemroot%%\SysWOW64 SET BIT=Y
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.:SETSOURCEFOLDER
>>%TEMP%.\cleanuns.cmd ECHO.	SET SOURCEFOLDER=%%~dp0
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.:TAKEOWNERSHIP
>>%TEMP%.\cleanuns.cmd ECHO.	ECHO Taking ownership of %PATH98%\%FILE98%
>>%TEMP%.\cleanuns.cmd ECHO.	takeown /a /f %PATH98%\%FILE98%
>>%TEMP%.\cleanuns.cmd ECHO.	ECHO Granting Admin rights
>>%TEMP%.\cleanuns.cmd ECHO.	ICACLS %PATH98%\%FILE98% /Grant Administrators:F
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.	ECHO Taking ownership of %%PATH99%%\%%FILE99%%
>>%TEMP%.\cleanuns.cmd ECHO.	takeown /a /f %%PATH99%%\%FILE99%%
>>%TEMP%.\cleanuns.cmd ECHO.	ECHO Granting Admin rights
>>%TEMP%.\cleanuns.cmd ECHO.	ICACLS %%PATH99%%\%%FILE99%% /Grant Administrators:F
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.:CLEANTEMPFILES
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.CD\
>>%TEMP%.\cleanuns.cmd ECHO.        attrib -H "%%PATH98%%\%%FILE98%%"
>>%TEMP%.\cleanuns.cmd ECHO.        del "%%PATH98%%\%%FILE98%%"
>>%TEMP%.\cleanuns.cmd ECHO.        attrib -H "%%PATH99%%\%%FILE99%%"
>>%TEMP%.\cleanuns.cmd ECHO.        del "%%PATH99%%\%%FILE99%%"
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\System32\imageres.TMP"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\System32\shell32.TMP"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\System32\imagesp1.TMP"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%windir%%\system32\imageres.OLD"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%windir%%\system32\shell32.OLD"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\System32\imagesp1.OLD"
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.     IF '%%BIT%%'=='Y' (
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\SysWOW64\imageres.TMP"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\SysWOW64\shell32.TMP"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\SysWOW64\imagesp1.TMP"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%windir%%\SysWOW64\imageres.OLD"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%windir%%\SysWOW64\shell32.OLD"
>>%TEMP%.\cleanuns.cmd ECHO.	del "%%WinDir%%\SysWOW64\imagesp1.OLD"
>>%TEMP%.\cleanuns.cmd ECHO.     ) ELSE (GOTO CLEANUPEND)
>>%TEMP%.\cleanuns.cmd ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.:CLEANUPEND
>>%TEMP%.\cleanuns.cmd ECHO.CLS
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.###########################################################
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##          Alumi Icon Pack 7600 X86 Uninstaller         ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##    -----------------------------------------------    ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##                                                       ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##                Uninstallation Complete!               ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##                                                       ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##   You may now restart 'UAC' once explorer starts up!  ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##                                                       ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.##                                                       ##
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.###########################################################
>>%TEMP%.\cleanuns.cmd ECHO.ECHO.
>>%TEMP%.\cleanuns.cmd ECHO.PAUSE
>>%TEMP%.\cleanuns.cmd ECHO.

REM - Add a reg key for RunOnce to run a cleanup script on restart...
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v "AlumiIconPack7600X86" /t REG_EXPAND_SZ /d "%TEMP%\cleanuns.cmd"


:SKIP64COPY


:STARTPROTECTIONSERVICES
        CLS		
	ECHO Starting Software Protection Services
	NET START "Software Protection"

:CONTINUE
ECHO.###########################################################
ECHO.##                                                       ##
ECHO.##                 Un-Install Complete!                  ##
ECHO.##                                                       ##
ECHO.##          You MUST Restart Windows before ALL          ##
ECHO.##                changes can take place.                ##
ECHO.##                                                       ##
ECHO.##                                                       ##
ECHO.###########################################################

:ASKAGAIN
ECHO.
ECHO.Restart Windows now?
ECHO.
ECHO.----------- 
ECHO.1. Yes.
ECHO.2. No.
ECHO.----------- 
set /p userinp2=Please choose a number(1-2):
set userinp2=%userinp2:~0,1%
if "%userinp2%"=="1" goto 1
if "%userinp2%"=="2" goto 2
ECHO.Invalid choice!
GOTO ASKAGAIN
:1
shutdown -r -t 01
GOTO END
:2
GOTO END

:NOINSTALLFOUND
ECHO.
ECHO.Alumi Icon Pack 7600 X86 MUST be installed first!
ECHO.
ECHO.Exiting without changes...
pause
GOTO EXITUNINSTALL
:END
        EXPLORER.EXE
:EXITUNINSTALL