@echo off
setlocal EnableDelayedExpansion
color 1f
title Speichenkarte deinstallieren
::-----------------------------------------------------------------------------------------------------------------------------
::-----------------------------------------------------------------------------------------------------------------------------
cd /d "%~dp0"

NET SESSION >nul 2>&1
IF %ERRORLEVEL% equ 0 (
cls
) else (
echo -----------------------------------------------------------
echo Du musst mich als Administrator ausfuehren!!
echo Script schliessen und so neu starten:
echo Rechte Taste auf _Deinstallieren.bat und dann 'als Administrator ausfuehren'
echo -----------------------------------------------------------
echo Taste druecken zum schliessen
pause >nul
echo bey
timeout 1 >nul
exit
)


:Anfang
tasklist |find /i "BaseCamp" >nul
if %errorlevel% == 0 (
echo Bitte BaseCamp schliessen
echo X
echo Danach Taste druecken....
pause >nul
cls
goto Anfang
)
tasklist |find /i "MapSource" >nul
if %errorlevel% == 0 (
echo Bitte MapSource schliessen
echo X
echo Danach Taste druecken....
pause >nul
cls
goto Anfang
)

set zln=0

set Name[1]=Speiche_Fabrik
set FamID[1]=7900
set MapID[1]=79000000
set HexID[1]=DC1E

set Name[2]=Speiche_NRW
set FamID[2]=7901
set MapID[2]=79010000
set HexID[2]=DD1E

set Name[3]=Speiche_BadenWuerttemberg
set FamID[3]=7902
set MapID[3]=79020000
set HexID[3]=DE1E

set Name[4]=Speiche_Bayern
set FamID[4]=7903
set MapID[4]=79030000
set HexID[4]=DF1E

set Name[5]=Speiche_Berlin
set FamID[5]=7904
set MapID[5]=79040000
set HexID[5]=E01E

set Name[6]=Speiche_Brandenburg
set FamID[6]=7905
set MapID[6]=79050000
set HexID[6]=E11E

set Name[7]=Speiche_Bremen
set FamID[7]=7906
set MapID[7]=79060000
set HexID[7]=E21E

set Name[8]=Speiche_Hamburg
set FamID[8]=7907
set MapID[8]=79070000
set HexID[8]=E31E

set Name[9]=Speiche_Hessen
set FamID[9]=7908
set MapID[9]=79080000
set HexID[9]=E41E

set Name[10]=Speiche_MecklenburgVorpommern
set FamID[10]=7909
set MapID[10]=79090000
set HexID[10]=E51E

set Name[11]=Speiche_Niedersachsen
set FamID[11]=7910
set MapID[11]=79100000
set HexID[11]=E61E

set Name[12]=Speiche_RheinlandPfalz
set FamID[12]=7911
set MapID[12]=79110000
set HexID[12]=E71E

set Name[13]=Speiche_Saarland
set FamID[13]=7912
set MapID[13]=79120000
set HexID[13]=E81E

set Name[14]=Speiche_Sachsen
set FamID[14]=7913
set MapID[14]=79130000
set HexID[14]=E91E

set Name[15]=Speiche_SachsenAnhalt
set FamID[15]=7914
set MapID[15]=79140000
set HexID[15]=EA1E

set Name[16]=Speiche_SchleswigHolstein
set FamID[16]=7915
set MapID[16]=79150000
set HexID[16]=EB1E

set Name[17]=Speiche_Thueringen
set FamID[17]=7916
set MapID[17]=79160000
set HexID[17]=EC1E

set Name[18]=Speiche_Kanaren
set FamID[18]=7917
set MapID[18]=79170000
set HexID[18]=ED1E

set Name[19]=Speiche_Deutschland
set FamID[19]=7920
set MapID[19]=79200000
set HexID[19]=F01E

set Name[20]=Speiche_NRWplus
set FamID[20]=7918
set MapID[20]=79180000
set HexID[20]=EE1E

set Name[21]=Speiche_Balearen
set FamID[21]=7919
set MapID[21]=79190000
set HexID[21]=EF1E

set Name[22]=Speiche_Alpen
set FamID[22]=7921
set MapID[22]=79210000
set HexID[22]=F11E

set Name[23]=Speiche_SuedOstEuropa
set FamID[23]=7922
set MapID[23]=79220000
set HexID[23]=F21E

set Name[24]=Speiche_Iberia
set FamID[24]=7923
set MapID[24]=79230000
set HexID[24]=F31E

set Name[25]=Speiche_Frankreich
set FamID[25]=7924
set MapID[25]=79240000
set HexID[25]=F41E

set Name[26]=Speiche_Italien
set FamID[26]=7925
set MapID[26]=79250000
set HexID[26]=F51E

set Name[27]=Speiche_Grossbritannien
set FamID[27]=7926
set MapID[27]=79260000
set HexID[27]=F61E

set Name[28]=Speiche_Daenemark
set FamID[28]=7927
set MapID[28]=79270000
set HexID[28]=F71E

set Name[29]=Speiche_Austria
set FamID[29]=7928
set MapID[29]=79280000
set HexID[29]=F81E

set Name[30]=Speiche_Norditalien_Suedtirol
set FamID[30]=7929
set MapID[30]=79290000
set HexID[30]=F91E

set Name[31]=Speiche_Norwegen
set FamID[31]=7943
set MapID[31]=79430000
set HexID[31]=071F

set Name[32]=Speiche_Irland
set FamID[32]=7931
set MapID[32]=79310000
set HexID[32]=FB1E

set Name[33]=Speiche_Ungarn
set FamID[33]=7932
set MapID[33]=79320000
set HexID[33]=FC1E

set Name[34]=Speiche_Slowakei
set FamID[34]=7933
set MapID[34]=79330000
set HexID[34]=FD1E

set Name[35]=Speiche_Rumaenien
set FamID[35]=7934
set MapID[35]=79340000
set HexID[35]=FE1E

set Name[36]=Speiche_Tschechien
set FamID[36]=7935
set MapID[36]=79350000
set HexID[36]=FF1E

set Name[37]=Speiche_Schweiz
set FamID[37]=7936
set MapID[37]=79360000
set HexID[37]=001F

set Name[38]=Speiche_Schweden
set FamID[38]=7944
set MapID[38]=79440000
set HexID[38]=081F

set Name[39]=Speiche_Polen
set FamID[39]=7938
set MapID[39]=79380000
set HexID[39]=021F

set Name[40]=Speiche_Iceland
set FamID[40]=7939
set MapID[40]=79390000
set HexID[40]=031F

set Name[41]=Speiche_FaroeIslands
set FamID[41]=7940
set MapID[41]=79400000
set HexID[41]=041F

set Name[42]=Speiche_AzorenMadeira
set FamID[42]=7941
set MapID[42]=79410000
set HexID[42]=051F

set Name[43]=Speiche_Finnland
set FamID[43]=7942
set MapID[43]=79420000
set HexID[43]=061F

set Name[44]=Speiche_Lettland
set FamID[44]=7945
set MapID[44]=79450000
set HexID[44]=091F

set Name[45]=Speiche_Litauen
set FamID[45]=7946
set MapID[45]=79460000
set HexID[45]=0a1F

set Name[46]=Speiche_Estland
set FamID[46]=7947
set MapID[46]=79470000
set HexID[46]=0b1F


set Name[47]=Speiche_Neuseeland
set FamID[47]=7948
set MapID[47]=79480000
set HexID[47]=0c1F
set XCYN[47]=y

set Name[48]=Speiche_Ukraine
set FamID[48]=7949
set MapID[48]=79490000
set HexID[48]=0D1F
set XCYN[48]=y

set Name[49]=Speiche_Georgien
set FamID[49]=7950
set MapID[49]=79500000
set HexID[49]=0e1f
set XCYN[49]=y

set Name[50]=Speiche_Liechtenstein
set FamID[50]=7951
set MapID[50]=79510000
set HexID[50]=0f1f
set XCYN[50]=y

set Name[51]=Speiche_Malta
set FamID[51]=7952
set MapID[51]=79520000
set HexID[51]=101f
set XCYN[51]=y

set Name[52]=Speiche_KapVerde
set FamID[52]=8953
set MapID[52]=89530000
set HexID[52]=111f
set XCYN[52]=y

set KEY=HKLM\SOFTWARE\Wow6432Node\Garmin\MapSource
if %PROCESSOR_ARCHITECTURE% == AMD64 goto key_ok
set KEY=HKLM\SOFTWARE\Garmin\MapSource
:key_ok

:anf

set /a "zln=%zln%+1"
if "!Name[%zln%]!" == "" goto schluss

if not exist !Name[%zln%]!.tdb goto anf
cd /d "%~dp0"
:falsch
echo -----------------------------------------------------------
echo Die Karte !Name[%zln%]! wird aus der Registry entfernt. Sicher?"
echo -----------------------------------------------------------
echo 1 - Karte entfernen
echo 2 - Karte behalten
echo -----------------------------------------------------------
echo Nummer der gewuenschten Aktion eingeben und Enter druecken
echo -----------------------------------------------------------
set /P  Abfr=
if /i "%Abfr%" == "1" goto weiter
if /i "%Abfr%" == "2" goto schluss
cls
goto falsch
:weiter
echo -----------------------------------------------------------
color 3f
reg DELETE %KEY%\Families\!Name[%zln%]! /f
echo -----------------------------------------------------------
echo Die Karte wurde aus der Windows-Registry entfernt.
echo Der Ordner mit den Kartendateien kann jetzt in den Muelleimer.
echo -----------------------------------------------------------


:schluss
echo ________________________________________________________
color ac
title !Name[%zln%]! Fertig!
echo !Name[%zln%]! fertig um %time%
::shutdown -s -f
echo Taste druecken zum schliessen
pause >nul
echo bey
timeout 1 >nul
exit