View the contents of a .CHM file on the console screen

This is a work in progress, but I have been using it with the TCMD.CHM file, and it does what it is supposed to do.

Thought others might find all or parts of it useful.

Note that it requires two external programs, 7z.exe, and W3M

Joe
Code:
::
:: View the contents of a .CHM file on the console screen
::
::     _x64: 1
::   _admin: 1
::_elevated: 1
::
::TCC  25.00.11 x64   Windows 10 [Version 10.0.18362.239]
::OS Name:                   Microsoft Windows 10 Pro
::OS Version:                10.0.18362 N/A Build 18362
::
:: Requires W3M, a text-based web browser
:: Requires 7z.exe, for extracting an .htm file from a .chm file
::
:: To view the list of .htm pages in a .chm file;
::  7z.exe l tcmd.chm | ffind /kvmt".htm" | *view
::
@setlocal
@echo off
set thechm="C:\Program Files\JPSoft\TCMD25\tcmd.chm"
iff exist %thechm then
  echo Found tcmd.chm file : %thechm
  Gosub 7zExist
else
  echo Could not locate %thechm
endlocal
quit

:7zExist
echos Looking for 7z.exe  :
which 7z.exe > nul
iff %_? eq 0 then
  echo  Found it!
  Gosub Proc1
else
  echo  Not Found!
  echo %_batchname requires 7z.exe
  echo Available from https://chocolatey.org/packages/7zip.install
endiff
Return

:Proc1
iff %# eq 1 then
  echo Found batch argument: %1
  Gosub Proc2
else
  echo USAGE: %_batchname f_doy
endiff
Return

:Proc2
::Store argc1 to environment variable
::
set thetopic=%1
::
:: Create an alias for w3m
::
alias w3m=wsl w3m
::
:: Extract the topic from the tcmd.chm file
::
7z.exe -y e %thechm %thetopic.htm > nul
::
iff not exist %thetopic.htm then
  echo Could not extract %thetopic from %thechm
  quit
endiff
::
:: View the help topic in the console
::
which w3m
iff %? ne 0 then
  echo Could not find w3m
  quit
else
  w3m -dump %thetopic.htm | *view
  if exist %thetopic.htm del /q %thetopic.htm
endiff
Return
 
Thread starter Similar threads Forum Replies Date
Joe Caverly T&T - Scripting 1
Joe Caverly T&T - Scripting 1