@echo off
::WcesComm is the name of the "Windows Mobile-2003-based device connectivity" service.
::RapiMgr is the name of the "Windows Mobile-based device connectivity" service.
::Both being necessary for proper WMDC functionality.

::The following registry entires set the RapiMgr and WcesComm services to run as seperate processes
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\RapiMgr /v SvcHostSplitDisable /t REG_DWORD /d 1 /f > nul 2>&1
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\WcesComm /v SvcHostSplitDisable /t REG_DWORD /d 1 /f > nul 2>&1
if %errorLevel% == 0 (
	echo Service Registry entries added successfully
    ) else (
        echo Failure: Please run this file as admin.
	goto end_Pause
    )
::Set the compatability of wmdc.exe to Windows Vista (which works more consistently)
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Windows\WindowsMobile\wmdc.exe" /d "~ VISTARTM" /f > nul 2>&1
if %errorLevel% == 0 (
	echo Compatability Mode for WMDC successfully set
    ) else (
        echo Failure: Please manually set the compatibility mode for
	echo C:\Windows\WindowsMobile\wmdc.exe
	echo to "Vista" for all users.
    )
echo.

::Stop both the services associated with WMDC
net stop WcesComm
net stop RapiMgr

::Set both the services to run as LocalSystem
sc config WcesComm obj= LocalSystem password= "" > nul 2>&1
sc config RapiMgr obj= LocalSystem password= "" > nul 2>&1
if %errorLevel% == 0 (
	echo Services configured to Log in As LocalSystem
    ) else (
        echo Failure: Services could not be updated
    )

echo.

::Restart the services. Starting WCesComm also starts RapiMgr
net start WcesComm

:end_Pause
pause