In Windows 7 and later version of Windows OS, when you click a Taskbar icon and more than one instance of a program is running, you will be presented with thumbnails of all the running instances.
![[Image: Ek2XFqU.png]](https://i.imgur.com/Ek2XFqU.png)
You can change this behavior with this batch script so that clicking the icon automatically displays the last running instance on the desktop (you can use Alt+Tab to switch to the others).
![[Image: Ek2XFqU.png]](https://i.imgur.com/Ek2XFqU.png)
You can change this behavior with this batch script so that clicking the icon automatically displays the last running instance on the desktop (you can use Alt+Tab to switch to the others).
Code
:: This batch script created by FreeBooter
@Echo Off & Color 1A
Cd %systemroot%\system32
REM --> Check for permissions
Reg query "HKU\S-1-5-19\Environment"
REM --> If error flag set, we do not have admin.
if %errorlevel% NEQ 0 (
ECHO **************************************
ECHO Running Admin shell... Please wait...
ECHO **************************************
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = "%*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
Cls & Mode CON LINES=11 COLS=70 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo ノヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘサ
Echo コ Do You Want To Open Last Active Program Window (Y/N)? コ
Echo ネヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘシ
Echo.
Echo.
Set /p input= RESPONSE:
If /i Not %input%==Y (Goto :_Ex) Else (Goto :_Start)
:_Ex
If /i Not %input%==N (Goto :EOF) Else (Goto :_RegRestore)
:_Start
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LastActiveClick" /t REG_DWORD /d "1" /f
Cls & Mode CON LINES=11 COLS=60 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo ノヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘサ
Echo コ Open Last Active Program Window Enabled コ
Echo ネヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘシ
Echo.
Echo.
Taskkill /im Explorer.exe /f >Nul
Start Explorer.exe
ping -n 8 localhost >Nul
Exit
:_RegRestore
Reg Query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LastActiveClick"
If %ErrorLevel% EQU 1 Goto :EOF
Reg Delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LastActiveClick" /f
Cls & Mode CON LINES=11 COLS=60 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo ノヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘサ
Echo コ Open Last Active Program Window Disabled コ
Echo ネヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘシ
Echo.
Echo.
Taskkill /im Explorer.exe /f >Nul
Start Explorer.exe
ping -n 8 localhost >nul
Exit
