Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for jthelp.bat

(view source code of jthelp.bat as plain text)

  1. @ECHO OFF
  2. IF "%OS%"=="Windows_NT" SETLOCAL
  3.  
  4. :: Version number for this batch file
  5. SET MyVer=1.01
  6.  
  7. :: Display "about"
  8. ECHO.
  9. ECHO JTHelp.bat,  Version %MyVer% for Windows 2000 / XP
  10. ECHO Generate an HTML help file for Microsoft's JT scheduler tool
  11. ECHO.
  12. ECHO This batch file was written by Rob van der Woude
  13. ECHO http://www.robvanderwoude.com
  14. ECHO.
  15. ECHO JT.EXE is part of Microsoft's Windows 2000 Resource Kit and
  16. ECHO is available at ftp://ftp.microsoft.com/reskit/win2000/jt.zip
  17. ECHO.
  18. ECHO.
  19. ECHO.
  20.  
  21. IF NOT "%OS%"=="Windows_NT" SET MyVer=
  22. IF NOT "%OS%"=="Windows_NT" GOTO End
  23.  
  24. :: Check if JT.EXE is available and if not, offer to download it
  25. ECHO Checking availability of JT scheduler tool . . .>CON
  26. SET JTAvailable=
  27. SET Download=
  28. JT.EXE /? >NUL 2>&1
  29. IF ERRORLEVEL 1 (
  30. 	SET JTAvailable=No
  31. 	ECHO.>CON
  32. 	ECHO This batch file requires Microsoft's JT utility.>CON
  33. 	SET /P Download=Do you want to download it now? [y/N] >CON
  34. )
  35.  
  36. :: Start download if requested
  37. IF /I "%Download%"=="Y" (
  38. 	START "JT" "ftp://ftp.microsoft.com/reskit/win2000/jt.zip"
  39. 	ECHO.>CON
  40. 	ECHO Install the downloaded file and make sure JT.EXE is in the PATH.>CON
  41. 	ECHO Then try again.>CON
  42. )
  43.  
  44. :: Abort if JT.EXE is not available yet
  45. IF "%JTAvailable%"=="No" GOTO End
  46.  
  47. ECHO Writing HTML header . . .>CON
  48. > jthelp.htm ECHO ^<HTML^>
  49. >>jthelp.htm ECHO ^<HEAD^>
  50. >>jthelp.htm ECHO ^<TITLE^>Help for Microsoft's JT scheduler tool^</TITLE^>
  51. >>jthelp.htm ECHO ^<META NAME="generator" CONTENT="JTHelp.bat, Version %MyVer%, by Rob van der Woude"^>
  52. >>jthelp.htm ECHO ^</HEAD^>
  53. >>jthelp.htm ECHO.
  54. >>jthelp.htm ECHO ^<BODY^>
  55. >>jthelp.htm ECHO.
  56. >>jthelp.htm ECHO ^<A NAME="Top"^>
  57. >>jthelp.htm ECHO.
  58. >>jthelp.htm ECHO ^<H1 ALIGN="center"^>Help for Microsoft's JT scheduler tool^</H1^>
  59. >>jthelp.htm ECHO.
  60. >>jthelp.htm ECHO ^<P^>^&nbsp;^</P^>
  61. >>jthelp.htm ECHO.
  62.  
  63. ECHO Writing JT main help . . .>CON
  64. SET EOH=0
  65. >>jthelp.htm ECHO ^<P^>
  66. FOR /F "tokens=1* delims=]" %%A IN ('JT.EXE /? 2^>^&1 ^| FIND.EXE /N /V ""') DO CALL :CmdHdr "%%~B" >>jthelp.htm
  67. >>jthelp.htm ECHO ^</P^>
  68.  
  69. >>jthelp.htm ECHO ^<TABLE^>
  70. FOR /F "tokens=1* delims=-" %%A IN ('JT.EXE /? ^| FIND.EXE " - "') DO CALL :Parse "%%~A" "%%~B" >>jthelp.htm 2>NUL
  71. >>jthelp.htm ECHO ^</TABLE^>
  72.  
  73. ECHO Writing footer . . .>CON
  74. >>jthelp.htm ECHO.
  75. >>jthelp.htm ECHO ^<P^>^&nbsp;^</P^>
  76. >>jthelp.htm ECHO.
  77. >>jthelp.htm ECHO ^<CENTER^>
  78. >>jthelp.htm ECHO ^<P^>This HTML help file and the associated text files were generated by:^<BR^>
  79. >>jthelp.htm ECHO ^<B^>JTHelp.bat^</B^>, Version %MyVer%^<BR^>
  80. >>jthelp.htm ECHO JTHelp.bat was written by Rob van der Woude^<BR^>
  81. >>jthelp.htm ECHO ^<A HREF="http://www.robvanderwoude.com"^>http://www.robvanderwoude.com^</A^>^</P^>
  82. >>jthelp.htm ECHO.
  83. >>jthelp.htm ECHO ^<P^>^&nbsp;^</P^>
  84. >>jthelp.htm ECHO.
  85. >>jthelp.htm ECHO ^<P^>JT.EXE is part of Microsoft's Windows 2000 Resource Kit^<BR^>
  86. >>jthelp.htm ECHO Download location: ^<A HREF="ftp://ftp.microsoft.com/reskit/win2000/jt.zip"^>ftp://ftp.microsoft.com/reskit/win2000/jt.zip^</A^>^</P^>
  87. >>jthelp.htm ECHO ^</CENTER^>
  88. >>jthelp.htm ECHO.
  89. >>jthelp.htm ECHO ^</BODY^>
  90. >>jthelp.htm ECHO ^</HTML^>
  91.  
  92. ECHO Done, now opening HTML file . . .>CON
  93. START jthelp.htm
  94.  
  95. ENDLOCAL
  96. GOTO:EOF
  97.  
  98.  
  99. :CmdHdr
  100. ECHO.%1 | FINDSTR.EXE /R /I "[\@/]" >NUL && SET EOH=1
  101. IF "%EOH%"=="1" GOTO:EOF
  102. IF NOT "%~1"=="" ECHO.%~1^<BR^>
  103. IF     "%~1"=="" ECHO.^</P^>
  104. GOTO:EOF
  105.  
  106.  
  107. :Parse
  108. :: JT dommand
  109. ECHO ^<TR^>
  110. SET Command=%1
  111. :: Escape special characters
  112. SET Command=%Command:<=^&lt;%
  113. SET Command=%Command:>=^&gt;%
  114. SET Command=%Command:|=^&brvbar;%
  115. :: Strip (most) trailing spaces
  116. SET Command=%Command:  = %
  117. SET Command=%Command:  = %
  118. SET Command=%Command:  = %
  119. SET Command=%Command:  = %
  120. :: Get first word in line and use it as the JT command name
  121. FOR /F "tokens=1 delims=/<|&> " %%a IN ('ECHO.%Command:"=%') DO SET Name=%%a
  122. IF "%Name%"=="?" SET Name=Help
  123. CALL :LoCase Name
  124. :: Create a separate text file for detailed help on each JT command
  125. ECHO Writing JT help text for %Name% command . . .>CON
  126. JT.EXE /? %Name% > jt_%Name%.txt 2>&1
  127. :: Append "Back" instruction to JT command text
  128. >> jt_%Name%.txt ECHO.
  129. >> jt_%Name%.txt ECHO.
  130. >> jt_%Name%.txt ECHO.
  131. >> jt_%Name%.txt ECHO.
  132. >> jt_%Name%.txt ECHO.
  133. >> jt_%Name%.txt ECHO.
  134. >> jt_%Name%.txt ECHO Click the Back button or press Backspace to return to the JT main page . . .
  135. :: Write HTML formated JT command
  136. ECHO     ^<TD^>^<A HREF="jt_%Name%.txt"^>^<CODE^>%Command:"=%^</CODE^>^</A^>^</TD^>
  137. :: JT command description
  138. SET Descr=%2
  139. :: Escape special characters
  140. SET Descr=%Descr:<=^&lt;%
  141. SET Descr=%Descr:>=^&gt;%
  142. SET Descr=%Descr:|=^&brvbar;%
  143. SET Descr=%Descr:(=^(%
  144. SET Descr=%Descr:)=^)%
  145. :: Write HTML formated JT command description
  146. ECHO     ^<TD^>%Descr:"=%^</TD^>
  147. ECHO ^</TR^>
  148. GOTO:EOF
  149.  
  150.  
  151. :LoCase
  152. :: Rename file to all lowercase
  153. SET TempVarName=%1
  154. CALL SET TempVarVal=%%%1%%
  155. SET TempVarVal=%TempVarVal:A=a%
  156. SET TempVarVal=%TempVarVal:B=b%
  157. SET TempVarVal=%TempVarVal:C=c%
  158. SET TempVarVal=%TempVarVal:D=d%
  159. SET TempVarVal=%TempVarVal:E=e%
  160. SET TempVarVal=%TempVarVal:F=f%
  161. SET TempVarVal=%TempVarVal:G=g%
  162. SET TempVarVal=%TempVarVal:H=h%
  163. SET TempVarVal=%TempVarVal:I=i%
  164. SET TempVarVal=%TempVarVal:J=j%
  165. SET TempVarVal=%TempVarVal:K=k%
  166. SET TempVarVal=%TempVarVal:L=l%
  167. SET TempVarVal=%TempVarVal:M=m%
  168. SET TempVarVal=%TempVarVal:N=n%
  169. SET TempVarVal=%TempVarVal:O=o%
  170. SET TempVarVal=%TempVarVal:P=p%
  171. SET TempVarVal=%TempVarVal:Q=q%
  172. SET TempVarVal=%TempVarVal:R=r%
  173. SET TempVarVal=%TempVarVal:S=s%
  174. SET TempVarVal=%TempVarVal:T=t%
  175. SET TempVarVal=%TempVarVal:U=u%
  176. SET TempVarVal=%TempVarVal:V=v%
  177. SET TempVarVal=%TempVarVal:W=w%
  178. SET TempVarVal=%TempVarVal:X=x%
  179. SET TempVarVal=%TempVarVal:Y=y%
  180. SET TempVarVal=%TempVarVal:Z=z%
  181. SET %TempVarName%=%TempVarVal%
  182. GOTO:EOF
  183.  
  184.  
  185. :End
  186. IF "%OS%"=="Windows_NT" ENDLOCAL
  187.  

page last modified: 2024-04-16; loaded in 0.0128 seconds