
@echo off
TITLE Creative Sound Blaster Audigy 5/Rx Driver Installation
VER
ECHO Creative Sound Blaster Audigy 5/Rx Driver Installation
DATE /T
TIME /T
SET /A INSTALLSTATUS = 0

:INSTALL64
echo Installing 64bit drivers set
REM xcopy /Y /Q "%~dp0Support\I386\CTIOM32_SBA5Rx.exe" %systemroot%\SysWOW64

echo UnInstall previous driver first if available ...
echo "... %~dp0Support\I386\CTIOM32_SBA5Rx.exe"
"%~dp0Support\I386\CTIOM32_SBA5Rx.exe"

echo "... %~dp0Support\I386\ctiom32.exe"
"%~dp0Support\I386\ctiom32.exe"
timeout /T 15


echo actual trigger driver installation...
echo ... "%systemroot%\system32\pnputil.exe" /add-driver "%~dp0wdm\wdma_emu.inf" /install
"%systemroot%\system32\pnputil.exe" /add-driver "%~dp0wdm\wdma_emu.inf" /install
timeout /T 15

rem xcopy /Y /F "%~dp0wdm\win2k_xp\data\ctp0612L.dat" %systemroot%\System32\Data
rem xcopy /Y /F "%~dp0wdm\win2k_xp\data\ctp1550w.dat" %systemroot%\System32\Data

rem xcopy /Y /F "%~dp0wdm\common\i386\killapps.exe" %systemroot%\SysWOW64
rem xcopy /Y /F "%~dp0wdm\common\i386\ENLOCSTR.exe" %systemroot%\SysWOW64
rem xcopy /Y /F "%~dp0wdm\common\i386\AddCat.exe" %systemroot%\SysWOW64
rem xcopy /Y /F "%~dp0wdm\common\amd64\UDAAIM64.exe" %systemroot%\SysWOW64
xcopy /Y /F "%~dp0wdm\common\amd64\REGPLIB.exe" %systemroot%\System32
xcopy /Y /F "%~dp0wdm\common\i386\REGPLIB.exe" %systemroot%\SysWOW64

echo ... %systemroot%\SysWOW64\killapps.exe
%systemroot%\SysWOW64\killapps.exe

echo ... %systemroot%\SysWOW64\AddCat.exe UDAAPO64.UDA
%systemroot%\SysWOW64\AddCat.exe UDAAPO64.UDA

echo ... %systemroot%\SysWOW64\UDAAIM64.exe /hidemsg /1: /s /g:{736EA663-603D-42fd-8C08-3209429F3C32}
%systemroot%\SysWOW64\UDAAIM64.exe /hidemsg /1: /s /g:{736EA663-603D-42fd-8C08-3209429F3C32}

echo ... Registering DLLs ...
echo ... regsvr32 /s %systemroot%\SysWOW64\CTDPROXY.dll
regsvr32 /s %systemroot%\SysWOW64\CTDPROXY.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\PIAPROXY.dll
regsvr32 /s %systemroot%\SysWOW64\PIAPROXY.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\A3D.dll
regsvr32 /s %systemroot%\SysWOW64\A3D.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\CTDC0000.dll
regsvr32 /s %systemroot%\SysWOW64\CTDC0000.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\CTDC0001.dll
regsvr32 /s %systemroot%\SysWOW64\CTDC0001.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\CTDCIFCE.dll
regsvr32 /s %systemroot%\SysWOW64\CTDCIFCE.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\CTMMACTL.dll
regsvr32 /s %systemroot%\SysWOW64\CTMMACTL.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\SysWOW64\UDAAPO32.DLL
regsvr32 /s %systemroot%\SysWOW64\UDAAPO32.DLL
rem timeout /T 1

rem echo ... regsvr32 /s %systemroot%\System32\PIAPROXY.dll
rem regsvr32 /s %systemroot%\System32\PIAPROXY.dll

echo ... regsvr32 /s %systemroot%\System32\CTDPXY64.dll
regsvr32 /s %systemroot%\System32\CTDPXY64.dll
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\System32\UDAAPO64.DLL
regsvr32 /s %systemroot%\System32\UDAAPO64.DLL
rem timeout /T 1

echo ... regsvr32 /s %systemroot%\System32\UDAPLD64.DLL
regsvr32 /s %systemroot%\System32\UDAPLD64.DLL
rem timeout /T 1

REM echo actual trigger driver installation...
REM echo ... "%systemroot%\system32\pnputil.exe" /add-driver "%~dp0wdm\wdma_emu.inf" /install
REM "%systemroot%\system32\pnputil.exe" /add-driver "%~dp0wdm\wdma_emu.inf" /install

echo ... RegPLIB DLLs ...
echo ... %systemroot%\SysWOW64\ENLOCSTR.exe %systemroot%\SysWow64\CTDNLSTR.dat
%systemroot%\SysWOW64\ENLOCSTR.exe %systemroot%\SysWow64\CTDNLSTR.dat

echo ... import entry if "%~dp0support\i386\EmupiaReg.reg
reg import "%~dp0support\i386\EmupiaReg.reg"
echo ... %systemroot%\SysWow64\REGPLIB.exe /S %systemroot%\SysWow64\CTEMUPIA.DLL
%systemroot%\SysWow64\REGPLIB.exe /S %systemroot%\SysWow64\CTEMUPIA.DLL


echo ... %systemroot%\System32\REGPLIB.exe /S /K2 COMMONFX.sys
%systemroot%\System32\REGPLIB.exe /S /K2 COMMONFX.sys

echo ... %systemroot%\System32\REGPLIB.exe /S /K2 CTAUDFX.sys
%systemroot%\System32\REGPLIB.exe /S /K2 CTAUDFX.sys

echo ... %systemroot%\System32\REGPLIB.exe /S /K2 CTSBLFX.sys
%systemroot%\System32\REGPLIB.exe /S /K2 CTSBLFX.sys

echo ... %systemroot%\System32\REGPLIB.exe /S /K2 CTERFXFX.sys
%systemroot%\System32\REGPLIB.exe /S /K2 CTERFXFX.sys

echo ... reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce" /v "DevconDefaultDB"  /t REG_EXPAND_SZ /d "%systemroot%\SysWOW64\READREG.EXE PSCONV={NO}" /f 
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce" /v "DevconDefaultDB"  /t REG_EXPAND_SZ /d "%systemroot%\SysWOW64\READREG.EXE PSCONV={NO}" /f

echo ... reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" /v "CTHelper"  /t REG_EXPAND_SZ /d "%systemroot%\SysWOW64\CtHelper.exe" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" /v "CTHelper"  /t REG_EXPAND_SZ /d "%systemroot%\SysWOW64\CtHelper.exe" /f

rem regsvr32 /S %systemroot%\SysWOW64\READREG.EXE,X,/SILENT
rem regsvr32 /S %systemroot%\SysWOW64\CTHELPER.EXE,X,/SILENT


IF [%1]==[] (
    echo not null LANG : %LANG%
    echo "Installing ENG strings..."
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "ENG" /f
    GOTO SET_INSTALL_DONE
) ELSE ( GOTO SET_INSTALL_LANG )

:SET_INSTALL_LANG
SET LANG=%1
echo "Selected %LANG% strings ..."

IF %LANG%==default (
    echo "Installing default ENG strings..."
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "ENG" /f
    GOTO SET_INSTALL_DONE
)

IF %LANG%==ENG (
    echo not null LANG : %LANG%
    echo "Installing ENG strings..."
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "ENG" /f
    GOTO SET_INSTALL_DONE
) 

IF %LANG%==BRZ (
    echo "Installing BRZ strings..."
    xcopy "%~dp0wdm\lang\ctbrz.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctbrz.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrbrz.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrbrz.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "BRZ" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "ITA"  /t REG_SZ /d "Data\CTITA.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESBRZ.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRBRZ.DLL" /f    
    GOTO SET_INSTALL_DONE
)
    
IF %LANG%==CHS (
    echo "Installing CHS strings..."
    xcopy "%~dp0wdm\lang\ctchs.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctchs.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrchs.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrchs.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "CHS" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "CHS"  /t REG_SZ /d "Data\CTCHS.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESCHS.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRCHS.DLL" /f
    GOTO SET_INSTALL_DONE
)
    
IF %LANG%==CHT (
    echo "Installing CHT strings..."
    xcopy "%~dp0wdm\lang\ctcht.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctcht.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrcht.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrcht.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "CHT" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "CHT"  /t REG_SZ /d "Data\CTCHT.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESCHT.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRCHT.DLL" /f
    GOTO SET_INSTALL_DONE
)
    
IF %LANG%==DUT (
    echo "Installing DUT strings..."
    xcopy "%~dp0wdm\lang\ctdut.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctdut.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrdut.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrdut.dll" %systemroot%\syswow64\ /Y /F

    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "DUT" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "DUT"  /t REG_SZ /d "Data\CTDUT.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESDUT.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRDUT.DLL" /f
    GOTO SET_INSTALL_DONE
)
    
IF %LANG%==FRN (
    echo "Installing FRN strings..."
    xcopy "%~dp0wdm\lang\ctfrn.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctfrn.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrfrn.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrfrn.dll" %systemroot%\syswow64\ /Y /F
		
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "FRN" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "FRN"  /t REG_SZ /d "Data\CTFRN.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESFRN.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRFRN.DLL" /f
    GOTO SET_INSTALL_DONE
)

IF %LANG%==GER (
    echo "Installing GER strings..."
    xcopy "%~dp0wdm\lang\ctger.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctger.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrger.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrger.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "GER" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "GER"  /t REG_SZ /d "Data\CTGER.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESGER.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRGER.DLL" /f
    GOTO SET_INSTALL_DONE
)
    
IF %LANG%==ITA (
    echo "Installing ITA strings..."
    xcopy "%~dp0wdm\lang\ctita.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctita.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrita.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrita.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "ITA" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "ITA"  /t REG_SZ /d "Data\CTITA.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESITA.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRITA.DLL" /f
    GOTO SET_INSTALL_DONE
)

IF %LANG%==JPN (
    echo "Installing JPN strings..."
    xcopy "%~dp0wdm\lang\ctjpn.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctjpn.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrjpn.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrjpn.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "JPN" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "JPN"  /t REG_SZ /d "Data\CTJPN.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESJPN.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRJPN.DLL" /f
    GOTO SET_INSTALL_DONE
)

IF %LANG%==KOR (
    echo "Installing KOR strings..."
    xcopy "%~dp0wdm\lang\ctkor.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctkor.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrkor.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrkor.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "KOR" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "KOR"  /t REG_SZ /d "Data\CTKOR.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESKOR.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRKOR.DLL" /f
    GOTO SET_INSTALL_DONE
)
    
IF %LANG%==POL (
    echo "Installing POL strings..."
    xcopy "%~dp0wdm\lang\ctpol.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctpol.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrpol.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrpol.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "POL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "POL"  /t REG_SZ /d "Data\CTPOL.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESPOL.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRPOL.DLL" /f
    GOTO SET_INSTALL_DONE
)

IF %LANG%==RUS (
    echo "Installing RUS strings..."
    xcopy "%~dp0wdm\lang\ctrus.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctrus.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrrus.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrrus.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "RUS" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "RUS"  /t REG_SZ /d "Data\CTRUS.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESRUS.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRRUS.DLL" /f
    GOTO SET_INSTALL_DONE
)

IF %LANG%==SPN (
    echo "Installing SPN strings..."
    xcopy "%~dp0wdm\lang\ctspn.dat" %systemroot%\system32\Data\ /Y /F 
    xcopy "%~dp0wdm\lang\ctspn.dat" %systemroot%\syswow64\Data\ /Y /F

    xcopy "%~dp0wdm\lang\amd64\ctdcrspn.dll" %systemroot%\system32\ /Y /F
    xcopy "%~dp0wdm\lang\i386\ctdcrspn.dll" %systemroot%\syswow64\ /Y /F
	
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database" /v "LangType"  /t REG_SZ /d "SPN" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\Lang" /v "SPN"  /t REG_SZ /d "Data\CTSPN.DAT" /f
    REM reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "InstallResource"  /t REG_SZ /d "%systemroot%\system32\INRESSPN.DLL" /f
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Creative Tech\Database\Product\LangResource" /v "DevconResource"  /t REG_SZ /d "%systemroot%\SysWOW64\CTDCRSPN.DLL" /f
    GOTO SET_INSTALL_DONE
)

:SET_INSTALL_DONE
echo LANG : %LANG%


@echo off
SET /A INSTALLSTATUS = 1
GOTO INSTALL_STATUS

:INSTALL_STATUS
IF %INSTALLSTATUS%==1 (GOTO INSTALLSUCCESS) ELSE (GOTO INSTALLFAIL)

:INSTALLSUCCESS
ECHO "+=====================================================================+"
ECHO "|                                                                     |"
ECHO "|                    Installation Successful!                         |"
ECHO "|                                                                     |"
ECHO "+=====================================================================+"
GOTO END

:INSTALLFAIL
ECHO "+=====================================================================+"
ECHO "|                    Installation Unsuccessful!                       |"
ECHO "|                                                                     |"
ECHO "|         In order to fully install the device, please go to          |"
ECHO "|     Microsoft Device Manager to continue to install the device      |"
ECHO "|                                                                     |"
ECHO "+=====================================================================+"
GOTO END

:END
ECHO "+======================================================================+"
ECHO "|                                                                      |"
ECHO "| Please reboot your system in order for your changes to be effective. |"
ECHO "|                                                                      |"
ECHO "+======================================================================+"

IF [%2]==[NOREBOOT_BAT] ( GOTO TONOREBOOTBAT )

echo Reboot? [Y/N]
set /p var=
IF /i %var%==y (shutdown /r /f /t 0) else exit

:TONOREBOOTBAT
echo NO REBOOT BAT

:ENDEND
