@echo off
REM only for test
set DKI_DEBUG=1
set DKI_RET=0

REM Initailisierung
%~d0
cd %~p0
set DKS_DRVINF=%~dp0DksDrv.inf

Echo Update PCW-Hardwaretreiber...
ver | find "2003" >NUL
if %ErrorLevel%==0 goto UPDATE_WIN_2003
ver | find "XP" >NUL
if %ErrorLevel%==0 goto UPDATE_WIN_XP
ver | find "6.0." >NUL
if %ErrorLevel%==0 goto UPDATE_WIN_VISTA
ver | find "6.1." >NUL
if %ErrorLevel%==0 goto UPDATE_WIN_7
ver | find "6.2." >NUL
if %ErrorLevel%==0 goto UPDATE_WIN_8

echo Fehler: Diese Windowsversion wird nicht unterstuetzt
ver
Exit 1
:UPDATE_WIN_XP
Echo Detect Windows XP
goto UPDATE_WIN_XP_1

:UPDATE_WIN_2003
Echo Detect Windows 2003
goto UPDATE_WIN_XP_1

:UPDATE_WIN_VISTA
Echo Detect Windows Vista
goto UPDATE_WIN_7_1

:UPDATE_WIN_8
Echo Detect Windows 8
goto UPDATE_WIN_7_1

:UPDATE_WIN_7
Echo Detect Windows 7

:UPDATE_WIN_7_1
set DKS_DEVCON=%windir%\system32\PnPUtil.exe
IF     "%PROCESSOR_ARCHITECTURE%"=="AMD64" GOTO UPDATE_WIN_7_1_2
IF NOT "%PROCESSOR_ARCHITEW6432%"=="AMD64" GOTO UPDATE_WIN_7_1_2
REM CMD.exe 32-Bit unter windows 64 Bit
set DKS_DEVCON=%windir%\sysnative\PnPUtil.exe
goto UPDATE_WIN_7_1_2

:UPDATE_WIN_7_1_2
if EXIST "%DKS_DEVCON%" goto UPDATE_WIN_7_2
echo Datei "%DKS_DEVCON%" nicht vorhanden
if "%DKI_DEBUG%"=="1" pause
Exit 1

:UPDATE_WIN_7_2
"%DKS_DEVCON%" -i -a "%DKS_DRVINF%"
set DKI_RET=%ErrorLevel%
if "%DKI_RET%"=="0"  GOTO UpdateDriver_OK
echo Fehler: %DKI_RET%
if "%DKI_DEBUG%"=="1" pause
Exit 1

:UPDATE_WIN_XP_1
REM Nur 32-Bit 
set DKS_DEVCON=%~dp0devcon.exe
REM exists devcon file 
if EXIST "%DKS_DEVCON%" goto UPDATE_WIN_XP_2
echo Datei "%DKS_DEVCON%" nicht vorhanden
if "%DKI_DEBUG%"=="1" pause
EXIT 1

:UPDATE_WIN_XP_2
"%DKS_DEVCON%" Update "%DKS_DRVINF%" "PCI\VEN_1803"
set DKI_RET=%ErrorLevel%
if "%DKI_RET%"=="0" goto UpdateDriver_OK
if "%DKI_RET%"=="1" goto UpdateDriver_OK
if "%DKI_DEBUG%"=="1" Echo DevCon update devices "1803:XXXX" FAILED
REM UPDATE PLX Devices 10B5:9050 SUBSYS_227010B5
"%DKS_DEVCON%" Update "%DKS_DRVINF%" "PCI\VEN_10B5&DEV_9050&SUBSYS_227010B5"
set DKI_RET=%ErrorLevel%
if "%DKI_RET%"=="0" goto UpdateDriver_OK
if "%DKI_RET%"=="1" goto UpdateDriver_OK
if "%DKI_DEBUG%"=="1" Echo DevCon update devices "10B5:9050" FAILED
echo Fehler: DevCon
if "%DKI_DEBUG%"=="1" pause
Exit 1

:UpdateDriver_OK
Echo Update PCW-Hardwaretreiber Ok
if "%DKI_DEBUG%"=="1" pause
Exit 0

