@ECHO OFF SET TempDir=IBMTemp MD "%TempDir%" :: Export registry tree to a temporary file START /WAIT REGEDIT /E "%TempDir%.\test1.dat" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CMDIDE" :: Read the required value from the temporary file FOR /F "tokens=1* delims==" %%A IN ('TYPE "%TempDir%.\test1.dat"') DO IF /I %%A=="Start" ECHO %%B > "%TEMPDIR%.\CMD.DAT" :: Search for the disabled value of 0x2 FINDSTR /I "dword:00000002" "%TEMPDIR%.\CMD.DAT" IF Errorlevel=1 GOTO TIDYUP :: Create the REG file ECHO Windows Registry Editor Version 5.00 >> "%TempDir%.\CMDREG.REG" ECHO. >> "%TempDir%.\CMDREG.REG" ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CmdIde] >> "%TempDir%.\CMDREG.REG" ECHO "Start"=dword:00000003 >> "%TempDir%.\CMDREG.REG" :: Apply the REG file REGEDIT /S "%TempDir%.\CMDREG.REG" :TIDYUP :: Delete the temporary files IF EXIST "%TempDir%.\test1.dat" DEL "%TempDir%.\test1.dat" IF EXIST "%TempDir%.\CMD.dat" DEL "%TempDir%.\CMD.dat" IF EXIST "%TempDir%.\CMDREG.REG" DEL "%TempDir%.\CMDREG.REG" IF EXIST "%TempDir%" RD "%TempDir%"