@ECHO OFF IF "%OS%"=="Windows_NT" SETLOCAL DISABLEDELAYEDEXPANSION :: Version number for this batch file SET MyVer=1.40 :: Display "about" ECHO. ECHO AllHelp.bat, Version %MyVer% for Windows NT 4 / 2000 / XP ECHO Generate an HTML help file for "all" available commands ECHO. ECHO Note: ECHO This batch file uses the redirected output of the HELP command to generate the ECHO HTML file. Because some commands use "special" characters like ^&, ^<, and ^> in ECHO their help screen, not all output is displayed correctly in the browser. ECHO Known issues: skipped ^ "tag" in CMD's special character list and skipped ECHO \^ word position references in FINDSTR's output. ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com ECHO. ECHO Improved white space handling by Johan Parlevliet ECHO Further improvements for NT 4 by Ulf Lindb„ck ECHO. ECHO. ECHO. IF NOT "%OS%"=="Windows_NT" SET MyVer= IF NOT "%OS%"=="Windows_NT" GOTO End :: Store current code page and then set code page for European languages FOR /F "tokens=*" %%A IN ('CHCP') DO FOR %%B IN (%%A) DO SET CHCP=%%B CHCP 1252 >NUL 2>&1 :: Start writing HTML file ECHO Writing HTML header . . . > allhelp.htm ECHO ^ >>allhelp.htm ECHO ^ >>allhelp.htm ECHO ^ :: Read Windows version using VER command FOR /F "tokens=1 delims=[" %%A IN ('VER') DO SET Ver=%%A FOR /F "tokens=1* delims= " %%A IN ('ECHO.%Ver%') DO SET Ver=%%B :: Read latest Service Pack from registry CALL :GetSP >>allhelp.htm ECHO ^Help for all %Ver%%SP% commands^ >>allhelp.htm ECHO ^ >>allhelp.htm ECHO ^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^ >>allhelp.htm ECHO ^%Ver%%SP% commands^ FOR /F "tokens=* delims=" %%A IN ('VER') DO SET Ver=%%A >>allhelp.htm ECHO ^%Ver%^ >>allhelp.htm ECHO ^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^^ ^ >>allhelp.htm ECHO. ECHO Creating command index table . . . SET FirstCell=1 >>allhelp.htm ECHO ^ :: Skip 1 or 2 lines of HELP command's header FOR /F "tokens=1 delims=[]" %%A IN ('HELP ^| FIND /N "."') DO IF %%A LEQ 2 SET Skip=+%%A :: MORE's /T switch translates tabs to a fixed number of spaces; tip by Johan Parlevliet :: In NT 4, MORE's /E switch may be necessary; tip by Ulf Lindb„ck :: %Skip% skips 1 or 2 lines of HELP command's header FOR /F "tokens=* delims=" %%A IN ('HELP ^| MORE /E %Skip% /T8') DO CALL :DispLine "%%A" >>allhelp.htm ECHO ^^ >>allhelp.htm ECHO ^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^^ ^ >>allhelp.htm ECHO. ECHO Writing help for each command: :: MORE's /T switch translates tabs to a fixed number of spaces; tip by Johan Parlevliet :: In NT 4, MORE's /E switch may be necessary; tip by Ulf Lindb„ck FOR /F "tokens=* delims=" %%A IN ('HELP ^| MORE /E %Skip% /T8') DO CALL :DispFull "%%A" ECHO Closing HTML file >>allhelp.htm ECHO. >>allhelp.htm ECHO ^
>>allhelp.htm ECHO ^This HTML file was generated by:^ >>allhelp.htm ECHO ^AllHelp.bat^, Version %MyVer% >>allhelp.htm ECHO for Windows NT^ 4^ /^ 2000^ /^ XP^ >>allhelp.htm ECHO Written by Rob van der Woude^ >>allhelp.htm ECHO ^http://www.robvanderwoude.com^^ >>allhelp.htm ECHO ^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^ >>allhelp.htm ECHO ^ ECHO. ECHO An HTML help file "allhelp.htm" has been created and stored in the current ECHO directory. ECHO. ECHO Now starting display of "allhelp.htm" . . . START "AllHelp" allhelp.htm :: End of main batch program CHCP %CHCP% >NUL 2>&1 ENDLOCAL GOTO:EOF :: Subroutines :DispLine SET Line=%1 SET Line=%Line:(=^(% SET Line=%Line:)=^)% SET Line=%Line:"=% SET Command=%Line:~0,8% SET Command=%Command: =% IF DEFINED Command CALL :DispCmdLine %Command% FOR /F "tokens=1* delims= " %%a IN ('ECHO.%*') DO SET Descr=%%b SET Descr=%Descr:"=% >>allhelp.htm ECHO.%Descr% GOTO:EOF :DispCmdLine IF "%FirstCell%"=="0" IF DEFINED Command (>>allhelp.htm ECHO ^^) SET Command=%1 IF DEFINED Command (>>allhelp.htm ECHO ^^
^%Command%^^^^ ^ ^ ^^) SET FirstCell=0 SET Command= GOTO:EOF :DispFull SET Line=%1 SET Command=%Line:~1,8% SET Command=%Command: =% IF DEFINED Command CALL :WriteFull %Command% SET Command= GOTO:EOF :GetSP SET SP= :: Export registry tree to temporary file START /WAIT REGEDIT.EXE /E "%Temp%.\%~n0.dat" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" IF NOT EXIST "%Temp%.\%~n0.dat" GOTO:EOF :: Read value of "CSDVersion" from temporary file FOR /F "tokens=2 delims==" %%A IN ('TYPE "%Temp%.\%~n0.dat" ^| FIND /I "CSDVersion"') DO SET SP=%%~A :: Check if value is valid ECHO.%SP% | FIND /I "Service Pack" >NUL IF ERRORLEVEL 1 SET SP= DEL "%Temp%.\%~n0.dat" :: Use a shorter notation IF DEFINED SP SET SP=%SP:Service Pack=SP% GOTO:EOF :WriteFull ECHO. %1 . . . >>allhelp.htm ECHO. >>allhelp.htm ECHO ^^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^%1^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^ >>allhelp.htm HELP %1 >>allhelp.htm ECHO ^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^Back to the top of this page^ >>allhelp.htm ECHO. >>allhelp.htm ECHO ^^ ^ >>allhelp.htm ECHO. GOTO:EOF :End