@echo off setlocal rem read or set IPoIB-CM registry values. rem If %2 value is supplied, then the RegKey operation is 'set', otherwise 'read'. if "%1" == "/?" ( :usage echo read/set IPoIB-CM registry values echo usage: cm reg-key {value} echo. echo example: cm CmPayloadMtu 4096 echo example: cm CmEnabled 1 exit /B 1 ) if "%1" == "" goto usage if "%1" == "-h" goto usage set B=%WINDIR%\temp rem CmEnabled 0/1 rem set K=CmPayloadMtu rem set V=4096 set K=%1 set V=%2 if "%2" == "" ( echo %COMPUTERNAME% reading IPoIB-CM reg Key %K% ) else ( echo %COMPUTERNAME% setting IPoIB-CM reg Key %K% value %V% ) set H=HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318} if exist del /Q %B%\foo.txt reg query %H% > %B%\foo.txt if ERRORLEVEL 1 ( echo ERR - reg query %H% ? echo Check %B%\foo.txt for error conditions. exit /B 1 ) for /f %%i in (%B%\foo.txt) do ( reg query %%i\ /v %K% > Nul 2>&1 if !ERRORLEVEL! EQU 0 ( if "%2" == "" ( reg query %%i\ /v %K% ) else ( reg add %%i\ /v %K% /t REG_SZ /d %V% /f ) ) ) if exist del /Q %B%\foo.txt endlocal