@echo off
:: Registering DynwrapX library ver 2.0. (Author of Library: U. Popov aka YMP (script-coding.com)
:: http://forum.script-coding.com/viewtopic.php?id=7328

echo This script must be run with Admin Privilegies
echo.

:: Checking system version
Set "xOS=x64"& If "%PROCESSOR_ARCHITECTURE%"=="x86" If Not Defined PROCESSOR_ARCHITEW6432 Set "xOS=x32"
echo System is %xOS%
echo.

:: Unregistering old DynwrapX library ver 1.0
regsvr32 /u /s "%windir%\system32\dynwrapx.dll"

if "%xOS%"=="x64" call :Reg_x64
if "%xOS%"=="x32" call :Reg_x32

echo.
pause
exit /B


:Reg_x32
  echo Registering x32 library

  copy /y "%~dp0dynwrapx\32\dynwrapx.dll" "%windir%\System32\*"
  regsvr32 /s "%windir%\System32\dynwrapx.dll"

  if %errorlevel%==0 (echo Registration - OK.) else (echo Registration - FAILED !!! Code: %errorlevel%)

Exit /B


:Reg_x64
  echo Registering x32 library

  copy /y "%~dp0dynwrapx\32\dynwrapx.dll" "%windir%\SysWOW64\*"
  regsvr32 /s "%windir%\SysWOW64\dynwrapx.dll"

  if %errorlevel%==0 (echo Registration - OK.) else (echo Registration - FAILED !!! Code: %errorlevel%)

  echo.
  echo Registering x64 library

  copy /y "%~dp0dynwrapx\64\dynwrapx.dll" "%windir%\System32\*"
  regsvr32 /s "%windir%\System32\dynwrapx.dll"

  if %errorlevel%==0 (echo Registration - OK.) else (echo Registration - FAILED !!! Code: %errorlevel%)
Exit /B
