Powered by GeSHi

Source code for allhelp.vbs

(view source code of allhelp.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim arrHelpWin, arrHelpWinChr1, arrIntCmd, arrTemp, dicHelpLong, dicHelpShort, dicSystemFiles
  4. Dim blnAdditional, blnDebug, blnDebugLog, blnIgnoreBatch, blnNohlpChr1, blnOverwrite, blnQuiet, blnWindowsOnly
  5. Dim intBitsOS, intCodePage, intOSVersion, intValidArgs, i, j
  6. Dim colItems, objDebugLog, objExec, objHTMLFile, objFolder
  7. Dim objFolderItem, objFSO, objItem, objKey, objMatches, objMatches2
  8. Dim objRE, objShell, objWMISvc, wshShell
  9. Dim strAlphabet, strClass, strCmdInfo, strCommand, strComSpec, strCSDVer, strFile, strFileVer
  10. Dim strDebugLog, strFirstLetter, strHelpAll, strHelpLong, strHelpShort, strHead, strHTML, strMsg, strNumVer
  11. Dim strOSLocl, strPattern, strPreviousLetter, strScriptVer, strUnknownCommand, strWinVer
  12.  
  13. Const INTERNAL_COMMON      = "BREAK CALL CD CHCP CHDIR CLS COPY DATE DEL DIR DPATH ECHO ERASE EXIT FOR GOTO IF MD MKDIR MOVE PATH PAUSE PROMPT RD REM REN RENAME RMDIR SET SHIFT TIME TYPE VER VERIFY VOL"
  14. Const INTERNAL_CMD_EXE     = "ASSOC COLOR ENDLOCAL FTYPE MKLINK POPD PUSHD SETLOCAL START TITLE"
  15. Const INTERNAL_COMMAND_COM = "CTTY LFNFOR LH LOADHIGH LOCK TRUENAME UNLOCK"
  16.  
  17. Const MY_DOCUMENTS = &H5
  18.  
  19. Const dictKey  = 1
  20. Const dictItem = 2
  21.  
  22. Const TristateFalse      =  0
  23. Const TristateMixed      = -2
  24. Const TristateTrue       = -1
  25. Const TristateUseDefault = -2
  26.  
  27. Const ForAppending = 8
  28. Const ForReading   = 1
  29. Const ForWriting   = 2
  30.  
  31. strDebugLog    = ""
  32. strMsg         = ""
  33. strScriptVer   = "3.25"
  34. intValidArgs   = 0
  35. blnAdditional  = False
  36. blnIgnoreBatch = True
  37. blnDebug       = False
  38. blnDebugLog    = False
  39. blnOverwrite   = False
  40. blnQuiet       = False
  41. blnWindowsOnly = False
  42.  
  43. intCodePage = GetCodePage( )
  44.  
  45. Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  46. Set wshShell = CreateObject( "Wscript.Shell" )
  47.  
  48.  
  49. With WScript.Arguments
  50. 	If .Named.Exists( "INCLUDEBATCH" ) And Not .Named.Exists( "NOBATCH" ) Then
  51. 		blnIgnoreBatch = False
  52. 		intValidArgs   = intValidArgs + 1
  53. 	End If
  54. 	If .Named.Exists( "NOBATCH" ) And Not .Named.Exists( "INCLUDEBATCH" ) Then
  55. 		blnIgnoreBatch = True
  56. 		intValidArgs   = intValidArgs + 1
  57. 	End If
  58. 	If .Named.Exists( "WHO" ) Then
  59. 		blnWindowsOnly = True
  60. 		intValidArgs   = intValidArgs + 1
  61. 	End If
  62. 	If .Named.Exists( "Q" ) Then
  63. 		blnQuiet     = True
  64. 		intValidArgs = intValidArgs + 1
  65. 	Else
  66. 		If .Named.Exists( "DEBUG" ) Then
  67. 			blnDebug     = True
  68. 			intValidArgs = intValidArgs + 1
  69. 			strDebugLog  = .Named.Item( "DEBUG" )
  70. 			If strDebugLog = "" Then
  71. 				blnDebugLog = False
  72. 			Else
  73. 				If objFSO.FolderExists( objFSO.GetParentFolderName( strDebugLog ) ) Then
  74. 					blnDebugLog = True
  75. 					Set objDebugLog = objFSO.OpenTextFile( strDebugLog, ForWriting, True, TristateUseDefault )
  76. 				Else
  77. 					blnDebugLog = False
  78. 				End If
  79. 			End If
  80. 			DebugDisplay "Show intermediate results"
  81. 			If blnDebugLog Then
  82. 				DebugDisplay "Logging to """ & strDebugLog & """"
  83. 			End If
  84. 		End If
  85. 		If .Named.Exists( "INCLUDEBATCH" ) Then
  86. 			If blnDebug Then DebugDisplay "Include batch files (.bat and .cmd)"
  87. 		Else
  88. 			If blnDebug Then DebugDisplay "Ignore batch files (.bat and .cmd)"
  89. 		End If
  90. 		If .Named.Exists( "WHO" ) Then
  91. 			If blnDebug Then DebugDisplay "Show commands listed by HELP only"
  92. 		Else
  93. 			If blnDebug Then DebugDisplay "Show ""all"" commands"
  94. 		End If
  95. 		If .Named.Exists( "Y" ) Then
  96. 			blnOverwrite = True
  97. 			intValidArgs = intValidArgs + 1
  98. 			If blnDebug Then DebugDisplay "HTML file overwrite ON"
  99. 		Else
  100. 			If blnDebug Then DebugDisplay "HTML file overwrite OFF"
  101. 		End If
  102. 		If .Unnamed.Count > 0 Then
  103. 			strFile = .Unnamed(0)
  104. 			intValidArgs = intValidArgs + 1
  105. 			If blnDebug Then DebugDisplay "Output HTML file: " & strFile
  106. 		Else
  107. 			' Find the path to "My Documents"
  108. 			Set objShell      = CreateObject( "Shell.Application" )
  109. 			Set objFolder     = objShell.Namespace( MY_DOCUMENTS )
  110. 			Set objFolderItem = objFolder.Self
  111. 			strFile = objFSO.BuildPath( objFolderItem.Path, "allhelp.html" )
  112. 			If blnDebug Then DebugDisplay "Output HTML file: " & strFile
  113. 			Set objFolderItem = Nothing
  114. 			Set objFolder     = Nothing
  115. 			Set objShell      = Nothing
  116. 		End If
  117. 		If objFSO.FileExists( strFile ) And Not blnOverwrite Then
  118. 			strMsg = strMsg & "ERROR: The specified output file exists and file overwrite is OFF" & vbCrLf & vbCrLf
  119. 			Syntax
  120. 		End If
  121. 		If objFSO.FolderExists( strFile ) Then
  122. 			strMsg = strMsg & "ERROR: A folder with the name of the specified output file exists" & vbCrLf & vbCrLf
  123. 			Syntax
  124. 		End If
  125. 		If Not objFSO.FolderExists( objFSO.GetParentFolderName( strFile ) ) Then
  126. 			strMsg = strMsg & "ERROR: The parent folder for the specified output file does not exists" & vbCrLf & vbCrLf
  127. 			Syntax
  128. 		End If
  129. 	End If
  130. 	If intValidArgs <> .Count Then
  131. 		strMsg = strMsg & "ERROR: Invalid command line arguments" & vbCrLf & vbCrLf
  132. 		Syntax
  133. 	End If
  134. End With
  135.  
  136. ' Get the OS version
  137. Set objWMISvc = GetObject( "winmgmts://./root/cimv2" )
  138. Set colItems  = objWMISvc.ExecQuery( "SELECT * FROM Win32_OperatingSystem", , 48 )
  139. For Each objItem in colItems
  140. 	strWinVer = objItem.Caption
  141. 	strCSDVer = objItem.CSDVersion
  142. 	strOSLocl = objItem.OSLanguage
  143. 	strNumVer = objItem.Version
  144. Next
  145.  
  146. ' Check if OS is 32-bit or 64-bit
  147. Set colItems  = objWMISvc.ExecQuery( "SELECT * FROM Win32_Processor", , 48 )
  148. For Each objItem in colItems
  149. 	intBitsOS = objItem.AddressWidth
  150. Next
  151. Set colItems  = Nothing
  152. Set objWMISvc = Nothing
  153.  
  154. ' Determine the list of internal commands, based on the command processor (COMMAND.COM or CMD.EXE)
  155. Set arrIntCmd = CreateObject( "System.Collections.Sortedlist" )
  156. strComSpec = UCase( wshShell.ExpandEnvironmentStrings( "%COMSPEC%" ) )
  157. arrTemp    = Split( INTERNAL_COMMON )
  158. For i = 0 To UBound( arrTemp )
  159. 	arrIntCmd.Add arrTemp(i), arrTemp(i)
  160. Next
  161. arrTemp = Null
  162. If Right( strComSpec, 12 ) = "\COMMAND.COM" Then
  163. 	arrTemp = Split( INTERNAL_COMMAND_COM )
  164. Else
  165. 	If Right( strComSpec, 8 ) = "\CMD.EXE" Then
  166. 		arrTemp = Split( INTERNAL_CMD_EXE )
  167. 	End If
  168. End If
  169. For i = 0 To UBound( arrTemp )
  170. 	arrIntCmd.Add arrTemp(i), arrTemp(i)
  171. Next
  172.  
  173. ' Change the working directory to %windir%\system32
  174. Set objShell = CreateObject( "Wscript.Shell" )
  175. objShell.CurrentDirectory = wshShell.ExpandEnvironmentStrings( "%windir%\system32" )
  176.  
  177. ' Retrieve the error message for unknown commands, i.e. what string to look for to detect errors
  178. strUnknownCommand = GetCommandError( )
  179.  
  180. ' Create a Dictionary objects to contain the commands and associated help texts
  181. Set dicHelpLong    = CreateObject( "Scripting.Dictionary" )
  182. Set dicHelpShort   = CreateObject( "Scripting.Dictionary" )
  183. Set dicSystemFiles = CreateObject( "Scripting.Dictionary" )
  184. Set arrHelpWin     = CreateObject( "System.Collections.ArrayList" )
  185. Set arrHelpWinChr1 = CreateObject( "System.Collections.ArrayList" )
  186.  
  187. ' Store all descriptions for files in %windir%\system32 in a dictionary for later use by GetFileDescription function.
  188. ' This speeds up this script enormously, when combined with a check in this dictionary first in GetFileDescription.
  189. GetSystemFileDescriptions
  190.  
  191. ' Fill the commands lists
  192. Set objExec = wshShell.Exec( "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": HELP&HELP)" )
  193. 'strHelpAll  = Escape( objExec.StdOut.ReadAll( ), intCodePage )
  194. strHelpAll  = objExec.StdOut.ReadAll( )
  195. objExec.Terminate
  196. Set objExec = Nothing
  197. Set objRE   = New RegExp
  198. objRE.Global     = True
  199. objRE.IgnoreCase = False
  200. objRE.Pattern    = "(^|[\n\r])[A-Z]+ +([^\n\r]+)(\r\n +([^\n\r]+))*"
  201. Set objMatches = objRE.Execute( strHelpAll )
  202. For i = 0 To objMatches.Count - 1
  203. 	strCommand   = Mid( objMatches.Item(i), 2, InStr( objMatches.Item(i), " " ) - 2 )
  204. 	strHelpShort = SuperTrim( Mid( objMatches.Item(i), InStr( objMatches.Item(i), " " ) ) )
  205. 	dicHelpShort.Add   strCommand, strHelpShort
  206. 	dicHelpLong.Add    strCommand, GetCmdHelp( strCommand )
  207. 	arrHelpWin.Add     strCommand
  208. 	arrHelpWinChr1.Add Left( strCommand, 1 )
  209. Next
  210. Set objMatches = Nothing
  211. Set objRE      = Nothing
  212.  
  213. ' Display intermediate results for debugging purposes
  214. If blnDebug Then
  215. 	strMsg = DebugDisplayHelpFound( )
  216. 	WScript.Echo strMsg
  217. 	If blnDebugLog Then
  218. 		On Error Resume Next
  219. 		objDebugLog.Write strMsg
  220. 		If Err Then
  221. 			WScript.Echo "==================================================="
  222. 			WScript.Echo "DEBUG: Error while trying to write to the log file:"
  223. 			WScript.Echo Err.Description
  224. 			WScript.Echo "==================================================="
  225. 		End If
  226. 		On Error Goto 0
  227. 	End If
  228. End if
  229.  
  230. If Not blnWindowsOnly Then
  231. 	AddCommand      "ACCESSCHK",     "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  232. 	AddCommand      "ACINIUPD",      ":[^\r\n]+",                                    "[^:\r\n][^\r\n]+"
  233. 	AddCommand      "ADRESTORE",     "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  234. 	AddCommand      "APPEND",        "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  235. 	AddCommand      "APPVERIF",      "[^\r\n]+",                                     "[^\r\n]+"
  236. 	AddCommand      "ARP",           "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "(\r\n[^\r\n]+)+"
  237. 	AddCommand      "AT",            "([^ ][^\r\n]+\r\n)+",                          "([^\r\n]+\r\n)+"
  238. 	AddCmdNoSummary "AUDITPOL"
  239. 	AddCommand      "AUTORUNSC",     "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  240. 	AddCommand      "BCDBOOT",       "[^\r\n]+\r\n\r\n([^\r\n\<]+\r\n)+",            "(.|\r|\n)+"
  241. 	AddCommand      "BITSADMIN",     "\r\n[^\r\n\(\[]+\r\n([^\r\n\(\[]+\r\n)*",      "([^\r\n]+\r\n)+"
  242. 	AddCommand      "BOOTCFG",       ":\r\n +[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "(\r\n +[^\r\n]+)+"
  243. 	AddCmdNoSummary "CDBURN"
  244. 	AddCmdNoSummary "CERTREQ"
  245. 	AddCmdNoSummary "CERTUTIL"
  246. 	AddCmdNoSummary "CHANGE"
  247. 	AddCommand      "CHGLOGON",      "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  248. 	AddCommand      "CHGPORT",       "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  249. 	AddCommand      "CHGUSR",        "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  250. 	AddCommand      "CHOICE",        "[\r\n]+CHOICE +\[ */[^\r\n]+[\r\n]+[A-Za-z ]+:[\r\n]+( +[^\/\r\n]+[\r\n]+)+[A-Za-z ]+:[\r\n]", "([\r\n]+ +[^\/\r\n]+)+[\r\n]"
  251. 	AddCommand      "CIPHER",        "([^ ][^\r\n]+\r\n)+",                          "([^\r\n]+\r\n)+"
  252. 	AddCommand      "CLIP",          ":\r\n +[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "([^:][^\r\n]+\r\n)+"
  253. 	AddCommand      "CMDKEY",        "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "(\r\n[^\r\n]+)+"
  254. 	AddCommand      "CONTIG",        "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  255. 	AddCommand      "COREINFO",      "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  256. 	AddCmdNoSummary "CSCRIPT"
  257. 	AddCommand      "CSVDE",         "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "(\r\n[^\r\n]+)+"
  258. 	AddCommand      "DCDIAG",        "([^\r\n]+[\r\n]{1,2})+",                       "([^\r\n]+[\r\n]{1,2})+"
  259. 	AddCommand      "DEBUG",         "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  260. 	AddCommand      "DEFRAG",        ":[\n\r]+(\s+[^\r\n]+[\r\n]+)+",                "([^\r\n:][^\r\n]+[\r\n]+)+"
  261. 	AddCommand      "DEVCON",        "[A-Z][^\r\n\[]+:[\r\n]{2,3}",                  "[^:\r\n]+"
  262. 	AddCmdNoSummary "DHCPLOC"
  263. 	AddCommand      "DIANTZ",        "([^\r\n\[]+ [^\r\n\[]+[\r\n]+)+",              "(.|\r|\n)+"
  264. 	AddCmdNoSummary "DISKPERF"
  265. 	AddCommand      "DISKRAID",      "[\r\n]([^\r\n\(]+[\r\n])+",                    "[\r\n]([^\r\n\(]+[\r\n])+"
  266. 	AddCommand      "DISM",          ":\r?\n\r?\n( +[^\r\n]+\r?\n)+\r?\n",           "([^:][^\r\n]+\r?\n)+"
  267. 	AddCommand      "DISPDIAG",      "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  268. 	AddCommand      "DPATH",         "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  269. 	AddCommand      "DSACLS",        "[A-Z][^\r\n\[]+[\r\n]{2,3}",                   "[^\r\n]+"
  270. 	AddCommand      "DSADD",         ": +[A-Z][^\r\n]+(\r\n[^\r\n]+)*:\r\n\r\n",     "[^:](.|\r|\n)+\."
  271. 	AddCommand      "DSDBUTIL",      "\n([^ \r\n\(][^\r\n\(]+\r?\n)+\r?\n",          "(.|\r|\n)+"
  272. 	AddCommand      "DSGET",         ": +[A-Z][^\r\n]+(\r\n[^\r\n]+)*:\r\n\r\n",     "[^:](.|\r|\n)+\."
  273. 	AddCommand      "DSMOD",         ": +[A-Z][^\r\n]+(\r\n[^\r\n]+)*:\r\n\r\n",     "[^:](.|\r|\n)+\."
  274. 	AddCommand      "DSMOVE",        ": +[A-Z][^\r\n]+(\r\n[^\r\n]+)*\r\n\r\n",      "[^:](.|\r|\n)+\."
  275. 	AddCommand      "DSQUERY",       ": +[A-Z][^\r\n]+(\r\n[^\r\n]+)*:\r\n\r\n",     "[^:](.|\r|\n)+\."
  276. 	AddCommand      "DSRM",          ": +[A-Z][^\r\n]+(\r\n[^\r\n]+)*\r\n\r\n",      "[^:](.|\r|\n)+\."
  277. 	AddCommand      "DU",            "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  278. 	AddCmdNoSummary "DVDBURN"
  279. 	AddCommand      "EDIT",          "[^\r\n]+\r\n([^\s\r\n][^\r\n]+\r\n)+",         "(.|\r|\n)+"
  280. 	AddCommand      "EDLIN",         "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  281. 	AddCommand      "EPAL",          "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  282. 	AddCommand      "EVENTCREATE",   ":\r\n +[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "(\r\n +[^\r\n]+)+"
  283. 	AddCommand      "EXE2BIN",       "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  284. 	AddCommand      "EXPAND",        "\r\n\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n", "(\r\n[^\r\n]+)+"
  285. 	AddCommand      "EXTRACT",       "\)[^\n\r]+\r\n",                               "[^\)\r\n][^\r\n]+"
  286. 	AddCommand      "FILEVER",       "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  287. 	AddCommand      "FINDLINKS",     "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  288. 	AddCommand      "FINGER",        "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "(\r\n[^\r\n]+)+"
  289. 	AddCmdNoSummary "FLTMC"
  290. 	AddCommand      "FORFILES",      ":\r\n +[A-Z][^\r\n]+(\r\n[^\r\n]+)*\r\n\r\n",  "(\r\n[^\r\n]+)+"
  291. 	AddCommand      "FTP",           "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "(\r\n[^\r\n]+)+"
  292. 	AddCommand      "GETMAC",        ":\r\n +[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "(\r\n +[^\r\n]+)+"
  293. 	AddCommand      "GPFIXUP",       "([^\r\n]+[\r\n]{2,3})+[\r\n]{2,3}",            "([^\r\n]+[\r\n]{2,3})+"
  294. 	AddCommand      "GPUPDATE",      ": +[A-Z][^\r\n]+[\r\n]{2,3}([^\r\n]+[\r\n]{2,3})*[\r\n]{4,6}", "([^:][^\r\n]+[\r\n]{2,3})+"
  295. 	AddCommand      "GRAFTABL",      "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  296. 	AddCommand      "HANDLE",        "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  297. 	AddCommand      "HEX2DEC",       "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  298. 	AddCommand      "HOSTNAME",      "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "(\r\n[^\r\n]+)+"
  299. 	AddCommand      "IFMEMBER",      "\r\n[^/]+\r\n",                                "(.|\r|\n)+"
  300. 	AddCmdNoSummary "IISRESET"
  301. 	AddCommand      "IPCONFIG",      "\r\n\r\n[A-Z][^\r\n]+\r\n([^\r\n\s][^\r\n]+\r\n)+\r\n", "([^\r\n]+\r\n)+"
  302. 	AddCommand      "ISCSICLI",      "([^\r\n]+ [^\r\n]+[\r\n]{1,2})+",              "(.|\r|\n)+"
  303. 	AddCommand      "JT",            "[^\r\n]+",                                     "(.|\r|\n)+"
  304. 	AddCommand      "JUNCTION",      "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  305. 	AddCommand      "LDIFDE",        "[\r\n]+([^\r\n]+ [^\r\n]+[\r\n]{1,2}[^=])+",   "([^\r\n]+ [^\r\n]+[\r\n]+)+"
  306. 	AddCommand      "LDMDUMP",       "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  307. 	AddCommand      "LISTDLLS",      "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  308. 	AddCommand      "LODCTR",        "\r\n +[A-Z][^\r\n]+\r\n( +[^\r\n]+\r\n)*\r\n", "([^\r\n]+\r\n)+"
  309. 	AddCommand      "LOGEVENT",      ": +[^\r\n]+\r\n([^\r\n]+\r\n)*",               "[^:][^\r\n]+\r\n([^\r\n]+\r\n)*"
  310. 	AddCommand      "LOGMAN",        "[\r\n]+[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "([^\r\n]+\r\n)+"
  311. 	AddCommand      "LOGOFF",        "[^\r\n]+\r\n",                                 "[^\r\n]+"
  312. 	AddCommand      "LOGONSESSIONS", "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  313. 	AddCommand      "MAKECAB",       "([^\r\n\[]+ [^\r\n\[]+[\r\n]+)+",              "(.|\r|\n)+"
  314. 	AddCommand      "MANAGE-BDE",    ":\r\n +([^:\r\n]+\r\n)+",                      "(\r\n[^:\r\n]+\r\n)+"
  315. 	AddCommand      "MEM",           "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  316. 	AddCommand      "MOUNTVOL",      "[\r\n]*[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "([^\r\n]+\r\n)+"
  317. 	AddCommand      "MOVEFILE",      "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\r\n]+"
  318. 	AddCmdNoSummary "MRINFO"
  319. 	AddCommand      "MSG",           "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  320. 	AddCommand      "NBTSTAT",       "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  321. 	AddCmdNoSummary "NET"
  322. 	AddCmdNoSummary "NETCFG"
  323. 	AddCmdNoSummary "NETDOM"
  324. 	AddCmdNoSummary "NETSH"
  325. 	AddCommand      "NETSTAT",       "[\r\n]*[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "([^\r\n]+\r\n)+"
  326. 	AddCommand      "NLSFUNC",       "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  327. 	AddCmdNoSummary "NLTEST"
  328. 	AddCmdNoSummary "NSLOOKUP"
  329. 	AddCommand      "NTDSUTIL",      "\n([^ \r\n\(][^\r\n\(]+\r?\n)+\r?\n",          "(.|\r|\n)+"
  330. 	AddCommand      "OPENFILES",     ":\r\n\s([^\r\n]+\r\n)+\r\n",                   "[^:](.|\r|\n)+"
  331. 	AddCmdNoSummary "PATHPING"
  332. 	AddCmdNoSummary "PING"
  333. 	AddCommand      "PNPUNATTEND",   ":[\r\n]+[^:\r\n]+",                            "[^:\r\n]+"
  334. 	AddCommand      "PNPUTIL",       "^[\n\r]*[^:\r\n]+[\n\r]+",                     "[^\n\r]+"
  335. 	AddCommand      "PORTQRY",       "[\r\n]*[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "([^\r\n]+\r\n)+"
  336. 	AddCommand      "POWERCFG",      ":\r\n +[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "(\r\n +[^\r\n]+)+"
  337. 	AddCommand      "PRINTBRM",      "^[\n\r]*[^\n\r]+",                             "[^\n\r]+"
  338. 	AddCommand      "PROCDUMP",      "^[\n\r]+(?:[^\n\r]+[\n\r]{1,3}){4}[\n\r]{1,3}((?:[^\n\r\-:\(]+[\n\r]{1,3}){1,2})[\n\r]+", "[\n\r]+([^\n\r\(\-]+[\n\r]{1,3})[\n\r]+"
  339. 	AddCommand      "PSEXEC",        "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  340. 	AddCommand      "PSFILE",        "([\r\n]{1,2}[A-Za-z .]+ [A-Za-z .]+)+\.",      "(.|\r|\n)+"
  341. 	AddCommand      "PSGETSID",      "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  342. 	AddCommand      "PSINFO",        "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  343. 	AddCommand      "PSKILL",        "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  344. 	AddCommand      "PSLIST",        "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  345. 	AddCommand      "PSLOGGEDON",    "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  346. 	AddCommand      "PSLOGLIST",     "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  347. 	AddCommand      "PSPASSWD",      "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  348. 	AddCommand      "PSPING",        "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  349. 	AddCommand      "PSSERVICE",     "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  350. 	AddCommand      "PSSHUTDOWN",    "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  351. 	AddCommand      "PSSUSPEND",     "- ([^\r\n\-]+[\r\n]{1,2})+",                   "[^-]([^\r\n]+\r\n)+"
  352. 	AddCommand      "QAPPSRV",       "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  353. 	AddCommand      "QPROCESS",      "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  354. 	AddCmdNoSummary "QUERY"
  355. 	AddCommand      "QUSER",         "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  356. 	AddCommand      "QWINSTA",       "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  357. 	AddCmdNoSummary "RASDIAL"
  358. 	AddCommand      "REAGENTC",      "([^\r\n\\<[]+[\r\n]+)+",                       "(.|\r|\n)+"
  359. 	AddCommand      "RECIMG",        "^([^\r\n]+\r\n)+",                             "(.|\r|\n)+"
  360. 	AddCommand      "RECOVER",       "[\r\n]*[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",  "([^\r\n]+\r\n)+"
  361. 	AddCmdNoSummary "REDIRCMP"
  362. 	AddCmdNoSummary "REDIRUSR"
  363. 	AddCmdNoSummary "REG"
  364. 	AddCommand      "REGDELNULL",    "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  365. 	AddCmdNoSummary "REGINI"
  366. 	AddCommand      "REGISTER-CIMPROVIDER", "([^\r\n\:]+[\r\n]+)+",                  "(.|\r|\n)+"
  367. 	AddCommand      "RELOG",         "[\r\n]+[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)+\r\n",  "([^\r\n]+\r\n)+"
  368. 	AddCommand      "RENDOM",        "[\r\n]([^\r\n\(\:]+[\r\n]+)+",                 "(.|\r|\n)+"
  369. 	AddCmdNoSummary "REPADMIN"
  370. 	AddCommand      "REPAIR-BDE",    "^[^\r\n\(]+[\r\n]+",                           "[^\r\n]+"
  371. 	AddCmdNoSummary "RESET"
  372. 	AddCommand      "ROUTE",         "\r\n[A-Z][^\r\n]+\r\n([^\r\n]+\r\n)*\r\n",     "([^\r\n]+\r\n)+"
  373. 	AddCmdNoSummary "RPCPING"
  374. 	AddCommand      "RU",            "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  375. 	AddCmdNoSummary "RUNAS"
  376. 	AddCmdNoSummary "SDBINST"
  377. 	AddCommand      "SDELETE",       "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  378. 	AddCmdNoSummary "SECEDIT"
  379. 	AddCommand      "SETVER",        "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  380. 	AddCommand      "SETX",          ":\r\n +[^\r\n/]+\r\n( +[^\r\n/]+\r\n)*",       "[^:](.|\r|\n)+"
  381. 	AddCommand      "SFC",           "[\r\n]([^\r\n\(\[]+[\r\n]{2,3})+",             "(.|\r|\n)+"
  382. 	AddCmdNoSummary "SHORTCUT"
  383. 	AddCommand      "SIGCHECK",      "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  384. 	AddCommand      "SOON",          ":[^:]*:",                                      "[^:]+"
  385. 	AddCommand      "STREAMS",       "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  386. 	AddCommand      "STRINGS",       "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  387. 	AddCommand      "SUBINACL",      "([^\r\n]+\r\n)+",                              "([^\r\n]+\r\n)+"
  388. 	AddCmdNoSummary "SXSTRACE"
  389. 	AddCommand      "SYNC",          "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  390. 	AddCommand      "TAKEOWN",       ":\r\n +[^\r\n]+\r\n( +[^\r\n]+\r\n)*",         "([^:\r\n][^\r\n]+\r\n)+"
  391. 	AddCommand      "TIMEOUT",       ":\r\n +[^\r\n]+\r\n( +[^\r\n]+\r\n)*",         "[^:](.|\r|\n)+"
  392. 	AddCmdNoSummary "TRACERPT"
  393. 	AddCmdNoSummary "TRACERT"
  394. 	AddCommand      "TSCON",         "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  395. 	AddCommand      "TSDISCON",      "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  396. 	AddCommand      "TSKILL",        "([^\r\n]+\r\n)+",                              "(.|\r|\n)+"
  397. 	AddCommand      "TYPEPERF",      "\)[\r\n]{2,4}([^\s\r\n][^\r\n]+[^:\r\n][\r\n]{2,4})+", "([^\)\s\r\n][^\r\n]+[\r\n]{2,4})+"
  398. 	AddCmdNoSummary "TZUTIL"
  399. 	AddCommand      "UNLODCTR",      "\r\n +[A-Z][^\r\n]+\r\n( +[^\r\n]+\r\n)*\r\n", "([^\r\n]+\r\n)+"
  400. 	AddCommand      "VAULTCMD",      "[^\r\n]+",                                     ".+"
  401. 	AddCmdNoSummary "VERIFIER"
  402. 	AddCommand      "VOLUMEID",      "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  403. 	AddCommand      "VSSADMIN",      "[^\(\r\n]+\r\n([^\(\r\n\(]+)*",                "([^\r\n]+\r\n)+"
  404. 	AddCmdNoSummary "W32TM"
  405. 	AddCommand      "WAITFOR",       ":\r\n +[^\r\n]+\r\n( +[^\r\n]+\r\n)*",         "[^:](.|\r|\n)+"
  406. 	AddCommand      "WBADMIN",       "[^\r\n]+",                                     ".+"
  407. 	AddCmdNoSummary "WECUTIL"
  408. 	AddCmdNoSummary "WEVTUTIL"
  409. 	AddCommand      "WHERE",         ":\r\n +[^\r\n]+\r\n( +[^\r\n]+\r\n)*",         "[^:](.|\r|\n)+"
  410. 	AddCommand      "WHOAMI",        "[^\d]:\r\n +[^\r\n]+\r\n( +[^\r\n]+\r\n)*",    "[^:]{2}(.|\r|\n)+"
  411. 	AddCommand      "WHOIS",         "^[\n\r]*[^\n\r]*[\n\r]+",                      "[^\n\r]+"
  412. 	AddCommand      "WINRM",         "\r\n[^\r\n]+\r\n([^\r\n]+\r\n)*",              "([^\r\n]+\r\n)+"
  413. 	AddCmdNoSummary "WINRS"
  414. 	AddCmdNoSummary "WMIC"
  415.  
  416. 	' Extra check for RUNAS, because it doesn't always use Standard Output
  417. 	If GetAddedCmdHelp( "RUNAS" ) <> "" Then
  418. 		AddCmdNoSummary "RUNAS"
  419. 	End If
  420.  
  421. 	' Sort the list of commands
  422. 	SortDictionary dicHelpShort, dictKey
  423.  
  424. 	' Display intermediate results for debugging purposes
  425. 	If blnDebug Then
  426. 		strMsg = DebugDisplayHelpFound( )
  427. 		WScript.Echo strMsg
  428. 		If blnDebugLog Then
  429. 			On Error Resume Next
  430. 			objDebugLog.Write strMsg
  431. 			If Err Then
  432. 				WScript.Echo "==================================================="
  433. 				WScript.Echo "DEBUG: Error while trying to write to the log file:"
  434. 				WScript.Echo Err.Description
  435. 				WScript.Echo "==================================================="
  436. 			End If
  437. 			On Error Goto 0
  438. 		End If
  439. 	End if
  440. End If
  441.  
  442. If blnDebug Then
  443. 	DebugDisplay Max( dicHelpShort.Count, dicHelpLong.Count ) & " commands processed," & vbCrLf _
  444. 	           & dicHelpShort.Count & " with summary," & vbCrLf _
  445. 	           & dicHelpLong.Count & " with long help text."
  446. End If
  447.  
  448. ' Create the head for the HTML page
  449. strHead = HTMLHead( )
  450.  
  451. ' Create the commands index for the HTML page
  452. strPreviousLetter = "@"
  453. strAlphabet       = "<table class=""Alphabet"">" & vbCrLf & "<tr>" & vbCrLf
  454. strHTML           = "<table class=""List"">" & vbCrLf
  455. For Each objKey In dicHelpShort.Keys( )
  456. 	strCommand = objKey
  457. 	' Only add the command if there is a help text or summary
  458. 	If Not SuperTrim( dicHelpLong.Item( strCommand ) ) & SuperTrim( dicHelpShort.Item( strCommand ) ) = "" Then
  459. 		strFileVer = FileVer( strCommand )
  460. 		If strFileVer <> "-1" Then
  461. 			If arrIntCmd.Contains( strCommand ) Then
  462. 				strClass = " class=""Internal"""
  463. 			Else
  464. 				If arrHelpWin.Contains( strCommand ) Then
  465. 					strClass = ""
  466. 				Else
  467. 					strClass = " class=""Additional"""
  468. 				End If
  469. 			End If
  470. 			If arrHelpWinChr1.Contains( Left( strCommand, 1 ) ) Then
  471. 				blnNohlpChr1 = False
  472. 			Else
  473. 				blnNohlpChr1 = True
  474. 			End If
  475. 			strFirstLetter = UCase( Left( strCommand, 1 ) )
  476. 			If strFirstLetter <> strPreviousLetter Then
  477. 				If strFirstLetter <> "A" Then
  478. 					strHTML = strHTML & "<tr"
  479. 					If blnNohlpChr1 Then strHTML = strHTML & strClass
  480. 					strhtml = strhtml & "><td colspan=""2"">&nbsp;</td></tr>" & vbCrLf
  481. 				End If
  482. 				strHTML = strHTML & "<tr id=""" & strFirstLetter & """"
  483. 				If blnNohlpChr1 Then strHTML = strHTML & strClass
  484. 				strHTML = strHTML _
  485. 				        & ">" _
  486. 				        & vbCrLf _
  487. 				        & vbTab & "<th colspan=""2"">" & strFirstLetter & "</th>" _
  488. 				        & vbCrLf _
  489. 				        & "</tr>" _
  490. 				        & vbCrLf _
  491. 				        & "<tr"
  492. 				If blnNohlpChr1 Then strHTML = strHTML & strClass
  493. 				strHTML = strHTML _
  494. 				        & "><td colspan=""2"">&nbsp;</td></tr>" _
  495. 				        & vbCrLf
  496. 				If strFirstLetter <> "A" Then
  497. 					If Asc( strFirstLetter ) - Asc( strPreviousLetter ) > 1 Then
  498. 						For i = Asc( strFirstLetter ) - Asc( strPreviousLetter ) - 1 To 1 Step -1
  499. 							strAlphabet = strAlphabet _
  500. 							            & vbTab & "<th style=""color: gray;"">" & Chr( Asc( strFirstLetter ) - i ) & "</th>" _
  501. 							            & vbCrLf
  502. 						Next
  503. 					End If
  504. 				End If
  505. 				strAlphabet = strAlphabet & vbTab & "<th><a href=""#" & strFirstLetter & """"
  506. 				If blnNohlpChr1 Then strAlphabet = strAlphabet & " class=""AdditionalChar"""
  507. 				strAlphabet = strAlphabet & ">" & strFirstLetter & "</a></th>" & vbCrLf
  508. 				strPreviousLetter = strFirstLetter
  509. 			End If
  510. 			strHTML = strHTML _
  511. 			        & "<tr" & strClass & ">" _
  512. 			        & vbCrLf
  513. 			If dicHelpLong.Exists( strCommand ) Then
  514. 				If dicHelpLong.Item( strCommand ) = "" Then
  515. 					strHTML = strHTML & vbTab & "<td class=""Command"">" & strCommand & "</td>" & vbCrLf
  516. 				Else
  517. 					strHTML = strHTML & vbTab & "<td class=""Command""><a href=""#" & strCommand & """>" & strCommand & "</a></td>" & vbCrLf
  518. 				End If
  519. 			End If
  520. 			strHTML = strHTML & vbTab & "<td>" & Escape( dicHelpShort.Item( strCommand ), intCodePage ) & "</td>" & vbCrLf
  521. 			'strHTML = strHTML & vbTab & "<td>" & dicHelpShort.Item( strCommand ) & "</td>" & vbCrLf
  522. 			strHTML = strHTML & "</tr>" & vbCrLf
  523. 		End If
  524. 	End If
  525. Next
  526. If strFirstLetter <> "Z" Then
  527. 	For i = 1 To Asc( "Z" ) - Asc( strFirstLetter )
  528. 		strAlphabet = strAlphabet & vbTab & "<th style=""color: gray;"">" & Chr( Asc( strFirstLetter ) + i ) & "</th>" & vbCrLf
  529. 	Next
  530. End If
  531. strHTML     = strHTML     & "</table>" & vbCrLf & vbCrLf
  532. If Not blnWindowsOnly Then
  533. 	strAlphabet = strAlphabet & vbTab & "<th><input type=""button"" id=""WinOnlyButton"" value=""Windows Help Only"" onclick=""toggleVisibility();""></th>" & vbCrLf
  534. End If
  535. strAlphabet = strAlphabet & "</tr>" & vbCrLf & "</table>" & vbCrLf & vbCrLf
  536. strHTML     = strHead & strAlphabet & "<p>&nbsp;</p>" & vbCrLf & vbCrLf & strHTML
  537.  
  538. ' Add detailed help for each command, if available
  539. For Each objKey In dicHelpShort.Keys( )
  540. 	strCommand = objKey
  541. 	' Only add the command if there is a help text
  542. 	If Not SuperTrim( dicHelpLong.Item( strCommand ) ) = "" Then
  543. 		strFileVer = FileVer( strCommand )
  544. 		If strFileVer <> "-1" Then
  545. 			If dicHelpLong.Exists( strCommand ) Then
  546. 				strHelpLong = Escape( dicHelpLong.Item( strCommand ), intCodePage )
  547. 				'strHelpLong = dicHelpLong.Item( strCommand )
  548. 				If strHelpLong <> "" Then
  549. 					If arrIntCmd.Contains( strCommand ) Then
  550. 						strHTML    = strHTML & "<div class=""InternalCommand"">" & vbCrLf & vbCrLf
  551. 						strCmdInfo = " &nbsp; <span style=""font-size: 60%;"">(internal command)</span>"
  552. 					Else
  553. 						If Not arrHelpWin.Contains( strCommand ) Then
  554. 							strHTML = strHTML & "<div class=""AdditionalHelp"">" & vbCrLf & vbCrLf
  555. 						End If
  556. 						If strFileVer = "" Then
  557. 							strCmdInfo = ""
  558. 						Else
  559. 							strCmdInfo = " &nbsp; <span style=""font-size: 60%;"">(Version " & strFileVer & ")</span>"
  560. 						End If
  561. 					End If
  562. 					strHTML = strHTML & "<p>&nbsp;</p>" & vbCrLf & vbCrLf _
  563. 					        & "<h2 id=""" & strCommand & """>" & strCommand & strCmdInfo & "</h2>" & vbCrLf & vbCrLf _
  564. 					        & "<pre>" & strHelpLong & "</pre>" & vbCrLf & vbCrLf _
  565. 					        & "<div style=""text-align: center;""><a href=""#"">Back to the top of this page</a></div>" & vbCrLf & vbCrLf
  566. 					If arrIntCmd.Contains( strCommand ) Or Not arrHelpWin.Contains( strCommand ) Then
  567. 						strHTML = strHTML & "</div>" & vbCrLf & vbCrLf
  568. 					End If
  569. 				End If
  570. 			End If
  571. 		End If
  572. 	End If
  573. Next
  574.  
  575. ' Write the "footer"
  576. strHTML = strHTML & HTMLFoot( )
  577.  
  578. 'Trim leading and trailing blank lines inside PRE blocks (workaround for CR/CR/LF bug)
  579. strHTML = TrimCrLf( strHTML )
  580.  
  581. If blnQuiet Then
  582. 	WScript.Echo strHTML
  583. Else
  584. 	' Write the complete HTML code to a file
  585. 	On Error Resume Next
  586. 	Set objHTMLFile = objFSO.CreateTextFile( strFile, True, False )
  587. 	objHTMLFile.Write strHTML
  588. 	Set objHTMLFile = Nothing
  589. 	If Err Then
  590. 		DebugDisplay "Error: " & Err.Description & vbCrLf & "Try ""ALLHELP.VBS /Q > ""outputfile"" if you cannot correct the error"
  591. 	End If
  592. 	On Error Goto 0
  593.  
  594. 	' Allow the virus scanner some time before opening the HTML file we just created
  595. 	WScript.Sleep 3000
  596.  
  597. 	'Open the HTML file
  598. 	wshShell.Run """" & strFile & """", 0, False
  599.  
  600. 	' Display this script's help screen when in debugging mode
  601. 	If blnDebug Then Syntax
  602. End If
  603.  
  604. If blnDebugLog Then
  605. 	objDebugLog.Close
  606. 	Set objDebugLog = Nothing
  607. End If
  608.  
  609. ' Close the last remaining objects
  610. Set objFSO   = Nothing
  611. Set wshShell = Nothing
  612.  
  613.  
  614.  
  615. Sub AddCommand( myCommand, myPattern1, myPattern2 )
  616. ' Check if a command is available and, if so, get its complete help text
  617. 	Dim objMatches, objMatches2, objRE, strCommand, strDebug, strFolder, wshShell
  618. 	strCommand = Trim( UCase( myCommand ) )
  619. 	If dicHelpShort.Item( strCommand ) = "" Then
  620. 		blnAdditional = True
  621. 		If blnDebug Then DebugDisplay "Trying to get help for the " & strcommand & " command:"
  622. 		' Get the complete help text for the command
  623. 		dicHelpLong.Item( strCommand ) = GetAddedCmdHelp( strCommand )
  624. 		' Try to extract the command help summary using two regular expressions
  625. 		Set objRE = New RegExp
  626. 		objRE.Global     = False
  627. 		objRE.IgnoreCase = False
  628. 		objRE.Pattern    = myPattern1
  629. 		Set objMatches = objRE.Execute( dicHelpLong.Item( strCommand ) )
  630. 		If blnDebug Then
  631. 			WScript.Echo "DEBUG: " & Right( Space( 3 ) & objMatches.Count, 3 ) & " match(es) for the regular expression"
  632. 			If objMatches.Count = 0 Then
  633. 				If dicHelpLong.Item( strCommand ) = "" Then
  634. 					WScript.Echo "DEBUG: Empty help text (unknown command?)"
  635. 				Else
  636. 					WScript.Echo "DEBUG: The following help text did not match:"
  637. 					WScript.Echo dicHelpLong.Item( strCommand )
  638. 				End If
  639. 			End If
  640. 			WScript.Echo String( Len( strDebug ), "=" ) & vbCrLf
  641. 		End If
  642. 		If objMatches.Count > 0 Then
  643. 			objRE.Pattern = myPattern2
  644. 			Set objMatches2 = objRE.Execute( objMatches.Item(0) )
  645. 			If objMatches2.Count > 0 Then
  646. 				dicHelpShort.Item( strCommand ) = SuperTrim( objMatches2.Item(0) )
  647. 			End If
  648. 			Set objMatches2 = Nothing
  649. 		End If
  650. 		Set objMatches = Nothing
  651. 		Set objRE      = Nothing
  652. 	End If
  653. 	' If no help text summary was found, try using the file description
  654. 	If dicHelpShort.Item( strCommand ) = "" Then
  655. 		If strCommand = "PRINTBMR" Then
  656. 			Set wshShell = CreateObject( "WScript.Shell" )
  657. 			strFolder = wshShell.ExpandEnvironmentStrings( "%windir%\system32\spool\tools" )
  658. 			Set wshShell = Nothing
  659. 		End If
  660. 		dicHelpShort.Item( strCommand ) = GetFileDescription( strCommand )
  661. 	End If
  662. 	' For debugging purposes
  663. 	If blnDebug Then
  664. 		DebugDisplay vbCrLf _
  665. 		           & "ShortHelp for """ & strCommand & """ is :" & dicHelpShort.Item( strCommand ) _
  666. 		           & vbCrLf _
  667. 		           & "LongHelp  for """ & strCommand & """ is :" & dicHelpLong.Item( strCommand )
  668. 	End If
  669. End Sub
  670.  
  671.  
  672.  
  673. Sub AddCmdNoSummary( myCommand )
  674. ' Add a command using the file description without checking for a command summary first
  675. 	Dim strCmdHelp, strCommand, strDebug, strFileDescription
  676. 	strCommand = Trim( UCase( myCommand ) )
  677. 	If Not dicHelpShort.Exists( strCommand ) Then
  678. 		blnAdditional = True
  679. 		If blnDebug Then
  680. 			strDebug = "DEBUG: Adding help for the " & strCommand & " command"
  681. 			WScript.Echo String( Len( strDebug ), "=" ) & vbCrLf & strDebug
  682. 			WScript.Echo String( Len( strDebug ), "=" ) & vbCrLf
  683. 		End If
  684. 		' Get the complete help text
  685. 		strCmdHelp         = GetAddedCmdHelp( strCommand )
  686. 		' Get the file description
  687. 		strFileDescription = GetFileDescription( strCommand )
  688. 		If ( strCmdHelp <> "" Or strFileDescription <> "" ) Then
  689. 			dicHelpLong.Add  strCommand, strCmdHelp
  690. 			dicHelpShort.Add strCommand, strFileDescription
  691. 		Else
  692. 			If blnDebug Then DebugDisplay "No help nor description available for " & strCommand
  693. 		End If
  694. 	End If
  695. End Sub
  696.  
  697.  
  698.  
  699. Sub DebugDisplay( myString )
  700. ' Format and then display debugging info
  701. 	Dim strSep, strMsg
  702. 	If blnQuiet Then Exit Sub
  703. 	strMsg = "DEBUG: " & myString
  704. 	strSep = String( Min( Len( strMsg ), 80 ), "=" )
  705. 	strMsg = strSep & vbCrLf & strMsg & vbCrLf & strSep & vbCrLf
  706. 	WScript.Echo strMsg
  707. 	If blnDebugLog Then
  708. 		On Error Resume Next
  709. 		objDebugLog.Write strMsg
  710. 		If Err Then
  711. 			WScript.Echo "=================================================="
  712. 			WScript.Echo "DEBUG: Error while trying to write to the log file"
  713. 			WScript.Echo "=================================================="
  714. 		End If
  715. 		On Error Goto 0
  716. 	End If
  717. End Sub
  718.  
  719.  
  720.  
  721. Function DebugDisplayHelpFound( )
  722. ' Show intermediate results
  723. 	Dim strMsg
  724. 	strMsg = "====================================" _
  725. 	       & vbCrLf _
  726. 	       & "DEBUG: The following help was found:" _
  727. 	       & vbCrLf _
  728. 	       & "====================================" _
  729. 	       & vbCrLf
  730. 	For Each objKey In dicHelpShort.Keys( )
  731. 		strMsg = strMsg & Left( objKey & Space( 16 ), 16 ) & Escape( dicHelpShort.Item( objKey ), intCodePage ) & vbCrLf
  732. 		' strMsg = strMsg & Left( objKey & Space( 16 ), 16 ) & dicHelpShort.Item( objKey ) & vbCrLf
  733. 	Next
  734. 	strMsg = strMsg _
  735. 	       & "====================================" _
  736. 	       & vbCrLf
  737. 	DebugDisplayHelpFound = strMsg
  738. End Function
  739.  
  740.  
  741.  
  742. Function Escape( myText, myCodePage )
  743. ' Remove characters that HTML cannot handle
  744. 	Dim strText
  745. 	strText = Replace( myText,  "&", "&amp;"  )
  746. 	strText = Replace( strText, "^", "&circ;" )
  747. 	strText = Replace( strText, "<", "&lt;"   )
  748. 	strText = Replace( strText, ">", "&gt;"   )
  749. 	Select Case myCodePage
  750. 		Case 437:
  751. 			strText = Replace( strText, Chr(160), "&aacute;" )
  752. 			strText = Replace( strText, Chr(131), "&acirc;"  )
  753. 			strText = Replace( strText, Chr(133), "&agrave;" )
  754. 			strText = Replace( strText, Chr(134), "&aring;"  )
  755. 			strText = Replace( strText, Chr(143), "&Aring;"  )
  756. 			strText = Replace( strText, Chr(132), "&auml;"   )
  757. 			strText = Replace( strText, Chr(142), "&Auml;"   )
  758. 			strText = Replace( strText, Chr(145), "&aelig;"  )
  759. 			strText = Replace( strText, Chr(146), "&AElig;"  )
  760. 			strText = Replace( strText, Chr(135), "&ccedil;" )
  761. 			strText = Replace( strText, Chr(128), "&Ccedil;" )
  762. 			strText = Replace( strText, Chr(130), "&eacute;" )
  763. 			strText = Replace( strText, Chr(144), "&Eacute;" )
  764. 			strText = Replace( strText, Chr(136), "&ecirc;"  )
  765. 			strText = Replace( strText, Chr(138), "&egrave;" )
  766. 			strText = Replace( strText, Chr(137), "&euml;"   )
  767. 			strText = Replace( strText, Chr(161), "&iacute;" )
  768. 			strText = Replace( strText, Chr(140), "&icirc;"  )
  769. 			strText = Replace( strText, Chr(141), "&igrave;" )
  770. 			strText = Replace( strText, Chr(139), "&iuml;"   )
  771. 			strText = Replace( strText, Chr(164), "&ntilde;" )
  772. 			strText = Replace( strText, Chr(165), "&Ntilde;" )
  773. 			strText = Replace( strText, Chr(162), "&oacute;" )
  774. 			strText = Replace( strText, Chr(147), "&ocirc;"  )
  775. 			strText = Replace( strText, Chr(149), "&ograve;" )
  776. 			strText = Replace( strText, Chr(148), "&ouml;"   )
  777. 			strText = Replace( strText, Chr(153), "&Ouml;"   )
  778. 			strText = Replace( strText, Chr(163), "&uacute;" )
  779. 			strText = Replace( strText, Chr(150), "&ucirc;"  )
  780. 			strText = Replace( strText, Chr(151), "&ugrave;" )
  781. 			strText = Replace( strText, Chr(129), "&uuml;"   )
  782. 			strText = Replace( strText, Chr(154), "&Uuml;"   )
  783. 			strText = Replace( strText, Chr(230), "&micro;"  )
  784. 			strText = Replace( strText, Chr(248), "&deg;"    )
  785. 			strText = Replace( strText, Chr(173), "&iexcl;"  )
  786. 			strText = Replace( strText, Chr(168), "&iquest;" )
  787. 			strText = Replace( strText, Chr(241), "&plusmn;" )
  788. 		Case 850:
  789. 			strText = Replace( strText, Chr(160), "&aacute;" )
  790. 			strText = Replace( strText, Chr(181), "&Aacute;" )
  791. 			strText = Replace( strText, Chr(131), "&acirc;"  )
  792. 			strText = Replace( strText, Chr(182), "&Acirc;"  )
  793. 			strText = Replace( strText, Chr(133), "&agrave;" )
  794. 			strText = Replace( strText, Chr(183), "&Agrave;" )
  795. 			strText = Replace( strText, Chr(134), "&aring;"  )
  796. 			strText = Replace( strText, Chr(143), "&Aring;"  )
  797. 			strText = Replace( strText, Chr(198), "&atilde;" )
  798. 			strText = Replace( strText, Chr(199), "&Atilde;" )
  799. 			strText = Replace( strText, Chr(132), "&auml;"   )
  800. 			strText = Replace( strText, Chr(142), "&Auml;"   )
  801. 			strText = Replace( strText, Chr(145), "&aelig;"  )
  802. 			strText = Replace( strText, Chr(146), "&AElig;"  )
  803. 			strText = Replace( strText, Chr(135), "&ccedil;" )
  804. 			strText = Replace( strText, Chr(128), "&Ccedil;" )
  805. 			strText = Replace( strText, Chr(130), "&eacute;" )
  806. 			strText = Replace( strText, Chr(144), "&Eacute;" )
  807. 			strText = Replace( strText, Chr(136), "&ecirc;"  )
  808. 			strText = Replace( strText, Chr(210), "&Ecirc;"  )
  809. 			strText = Replace( strText, Chr(138), "&egrave;" )
  810. 			strText = Replace( strText, Chr(212), "&Egrave;" )
  811. 			strText = Replace( strText, Chr(137), "&euml;"   )
  812. 			strText = Replace( strText, Chr(211), "&Euml;"   )
  813. 			strText = Replace( strText, Chr(161), "&iacute;" )
  814. 			strText = Replace( strText, Chr(214), "&Iacute;" )
  815. 			strText = Replace( strText, Chr(140), "&icirc;"  )
  816. 			strText = Replace( strText, Chr(215), "&Icirc;"  )
  817. 			strText = Replace( strText, Chr(141), "&igrave;" )
  818. 			strText = Replace( strText, Chr(222), "&Igrave;" )
  819. 			strText = Replace( strText, Chr(139), "&iuml;"   )
  820. 			strText = Replace( strText, Chr(216), "&Iuml;"   )
  821. 			strText = Replace( strText, Chr(164), "&ntilde;" )
  822. 			strText = Replace( strText, Chr(165), "&Ntilde;" )
  823. 			strText = Replace( strText, Chr(162), "&oacute;" )
  824. 			strText = Replace( strText, Chr(224), "&Oacute;" )
  825. 			strText = Replace( strText, Chr(147), "&ocirc;"  )
  826. 			strText = Replace( strText, Chr(226), "&Ocirc;"  )
  827. 			strText = Replace( strText, Chr(149), "&ograve;" )
  828. 			strText = Replace( strText, Chr(227), "&Ograve;" )
  829. 			strText = Replace( strText, Chr(228), "&otilde;" )
  830. 			strText = Replace( strText, Chr(229), "&Otilde;" )
  831. 			strText = Replace( strText, Chr(148), "&ouml;"   )
  832. 			strText = Replace( strText, Chr(153), "&Ouml;"   )
  833. 			strText = Replace( strText, Chr(163), "&uacute;" )
  834. 			strText = Replace( strText, Chr(233), "&Uacute;" )
  835. 			strText = Replace( strText, Chr(150), "&ucirc;"  )
  836. 			strText = Replace( strText, Chr(234), "&Ucirc;"  )
  837. 			strText = Replace( strText, Chr(151), "&ugrave;" )
  838. 			strText = Replace( strText, Chr(235), "&Ugrave;" )
  839. 			strText = Replace( strText, Chr(129), "&uuml;"   )
  840. 			strText = Replace( strText, Chr(154), "&Uuml;"   )
  841. 			strText = Replace( strText, Chr(236), "&yacute;" )
  842. 			strText = Replace( strText, Chr(237), "&Yacute;" )
  843. 			strText = Replace( strText, Chr(225), "&szlig;"  )
  844. 			strText = Replace( strText, Chr(230), "&micro;"  )
  845. 			strText = Replace( strText, Chr(248), "&deg;"    )
  846. 			strText = Replace( strText, Chr(173), "&iexcl;"  )
  847. 			strText = Replace( strText, Chr(191), "&iquest;" )
  848. 			strText = Replace( strText, Chr(169), "&copy;"   )
  849. 			strText = Replace( strText, Chr(174), "&reg;"    )
  850. 			strText = Replace( strText, Chr(171), "&laquo;"  )
  851. 			strText = Replace( strText, Chr(175), "&raquo;"  )
  852. 			strText = Replace( strText, Chr(241), "&plusmn;" )
  853. 			strText = Replace( strText, Chr(244), "&para;"   )
  854. 		Case 1252
  855. 			strText = Replace( strText, Chr(128), "&euro;"   )
  856. 			strText = Replace( strText, Chr(130), "&sbquo;"  )
  857. 			strText = Replace( strText, Chr(131), "&fnof;"   )
  858. 			strText = Replace( strText, Chr(132), "&bdquo;"  )
  859. 			strText = Replace( strText, Chr(136), "&circ;"   )
  860. 			strText = Replace( strText, Chr(137), "&permil;" )
  861. 			strText = Replace( strText, Chr(138), "&Scaron;" )
  862. 			strText = Replace( strText, Chr(139), "&lsaquo;" )
  863. 			strText = Replace( strText, Chr(140), "&OElig;"  )
  864. 			strText = Replace( strText, Chr(142), "&Zcaron;" )
  865. 			strText = Replace( strText, Chr(145), "&lsquo;"  )
  866. 			strText = Replace( strText, Chr(146), "&rsquo;"  )
  867. 			strText = Replace( strText, Chr(147), "&ldquo;"  )
  868. 			strText = Replace( strText, Chr(148), "&rdquo;"  )
  869. 			strText = Replace( strText, Chr(149), "&bull;"   )
  870. 			strText = Replace( strText, Chr(150), "&ndash;"  )
  871. 			strText = Replace( strText, Chr(151), "&mdash;"  )
  872. 			strText = Replace( strText, Chr(152), "&tilde;"  )
  873. 			strText = Replace( strText, Chr(153), "&trade;"  )
  874. 			strText = Replace( strText, Chr(154), "&scaron;" )
  875. 			strText = Replace( strText, Chr(155), "&rsaquo;" )
  876. 			strText = Replace( strText, Chr(156), "&oelig;"  )
  877. 			strText = Replace( strText, Chr(158), "&zcaron;" )
  878. 			strText = Replace( strText, Chr(159), "&Yuml;"   )
  879. 			strText = Replace( strText, Chr(161), "&iexcl;"  )
  880. 			strText = Replace( strText, Chr(162), "&cent;"   )
  881. 			strText = Replace( strText, Chr(163), "&pound;"  )
  882. 			strText = Replace( strText, Chr(164), "&curren;" )
  883. 			strText = Replace( strText, Chr(165), "&yen;"    )
  884. 			strText = Replace( strText, Chr(166), "&brvbar;" )
  885. 			strText = Replace( strText, Chr(167), "&sect;"   )
  886. 			strText = Replace( strText, Chr(168), "&uml;"    )
  887. 			strText = Replace( strText, Chr(169), "&copy;"   )
  888. 			strText = Replace( strText, Chr(170), "&ordf;"   )
  889. 			strText = Replace( strText, Chr(171), "&laquo;"  )
  890. 			strText = Replace( strText, Chr(172), "&not;"    )
  891. 			strText = Replace( strText, Chr(173), "&shy;"    )
  892. 			strText = Replace( strText, Chr(174), "&reg;"    )
  893. 			strText = Replace( strText, Chr(175), "&macr;"   )
  894. 			strText = Replace( strText, Chr(176), "&deg;"    )
  895. 			strText = Replace( strText, Chr(177), "&plusmn;" )
  896. 			strText = Replace( strText, Chr(178), "&sup2;"   )
  897. 			strText = Replace( strText, Chr(179), "&sup3;"   )
  898. 			strText = Replace( strText, Chr(180), "&acute;"  )
  899. 			strText = Replace( strText, Chr(181), "&micro;"  )
  900. 			strText = Replace( strText, Chr(182), "&para;"   )
  901. 			strText = Replace( strText, Chr(183), "&middot;" )
  902. 			strText = Replace( strText, Chr(184), "&cedil;"  )
  903. 			strText = Replace( strText, Chr(185), "&sup1;"   )
  904. 			strText = Replace( strText, Chr(186), "&ordm;"   )
  905. 			strText = Replace( strText, Chr(187), "&raquo;"  )
  906. 			strText = Replace( strText, Chr(188), "&frac14;" )
  907. 			strText = Replace( strText, Chr(189), "&frac12;" )
  908. 			strText = Replace( strText, Chr(190), "&frac34;" )
  909. 			strText = Replace( strText, Chr(191), "&iquest;" )
  910. 			strText = Replace( strText, Chr(192), "&Agrave;" )
  911. 			strText = Replace( strText, Chr(193), "&Aacute;" )
  912. 			strText = Replace( strText, Chr(194), "&Acirc;"  )
  913. 			strText = Replace( strText, Chr(195), "&Atilde;" )
  914. 			strText = Replace( strText, Chr(196), "&Auml;"   )
  915. 			strText = Replace( strText, Chr(197), "&Aring;"  )
  916. 			strText = Replace( strText, Chr(198), "&AElig;"  )
  917. 			strText = Replace( strText, Chr(199), "&Ccedil;" )
  918. 			strText = Replace( strText, Chr(200), "&Egrave;" )
  919. 			strText = Replace( strText, Chr(201), "&Eacute;" )
  920. 			strText = Replace( strText, Chr(202), "&Ecirc;"  )
  921. 			strText = Replace( strText, Chr(203), "&Euml;"   )
  922. 			strText = Replace( strText, Chr(204), "&Igrave;" )
  923. 			strText = Replace( strText, Chr(205), "&Iacute;" )
  924. 			strText = Replace( strText, Chr(206), "&Icirc;"  )
  925. 			strText = Replace( strText, Chr(207), "&Iuml;"   )
  926. 			strText = Replace( strText, Chr(208), "&ETH;"    )
  927. 			strText = Replace( strText, Chr(209), "&Ntilde;" )
  928. 			strText = Replace( strText, Chr(210), "&Ograve;" )
  929. 			strText = Replace( strText, Chr(211), "&Oacute;" )
  930. 			strText = Replace( strText, Chr(212), "&Ocirc;"  )
  931. 			strText = Replace( strText, Chr(213), "&Otilde;" )
  932. 			strText = Replace( strText, Chr(214), "&Ouml;"   )
  933. 			strText = Replace( strText, Chr(215), "&times;"  )
  934. 			strText = Replace( strText, Chr(216), "&Oslash;" )
  935. 			strText = Replace( strText, Chr(217), "&Ugrave;" )
  936. 			strText = Replace( strText, Chr(218), "&Uacute;" )
  937. 			strText = Replace( strText, Chr(219), "&Ucirc;"  )
  938. 			strText = Replace( strText, Chr(220), "&Uuml;"   )
  939. 			strText = Replace( strText, Chr(221), "&Yacute;" )
  940. 			strText = Replace( strText, Chr(222), "&THORN;"  )
  941. 			strText = Replace( strText, Chr(223), "&szlig;"  )
  942. 			strText = Replace( strText, Chr(224), "&agrave;" )
  943. 			strText = Replace( strText, Chr(225), "&aacute;" )
  944. 			strText = Replace( strText, Chr(226), "&acirc;"  )
  945. 			strText = Replace( strText, Chr(227), "&atilde;" )
  946. 			strText = Replace( strText, Chr(228), "&auml;"   )
  947. 			strText = Replace( strText, Chr(229), "&aring;"  )
  948. 			strText = Replace( strText, Chr(230), "&aelig;"  )
  949. 			strText = Replace( strText, Chr(231), "&ccedil;" )
  950. 			strText = Replace( strText, Chr(232), "&egrave;" )
  951. 			strText = Replace( strText, Chr(233), "&eacute;" )
  952. 			strText = Replace( strText, Chr(234), "&ecirc;"  )
  953. 			strText = Replace( strText, Chr(235), "&euml;"   )
  954. 			strText = Replace( strText, Chr(236), "&igrave;" )
  955. 			strText = Replace( strText, Chr(237), "&iacute;" )
  956. 			strText = Replace( strText, Chr(238), "&icirc;"  )
  957. 			strText = Replace( strText, Chr(239), "&iuml;"   )
  958. 			strText = Replace( strText, Chr(240), "&eth;"    )
  959. 			strText = Replace( strText, Chr(241), "&ntilde;" )
  960. 			strText = Replace( strText, Chr(242), "&ograve;" )
  961. 			strText = Replace( strText, Chr(243), "&oacute;" )
  962. 			strText = Replace( strText, Chr(244), "&ocirc;"  )
  963. 			strText = Replace( strText, Chr(245), "&otilde;" )
  964. 			strText = Replace( strText, Chr(246), "&ouml;"   )
  965. 			strText = Replace( strText, Chr(247), "&divide;" )
  966. 			strText = Replace( strText, Chr(248), "&oslash;" )
  967. 			strText = Replace( strText, Chr(249), "&ugrave;" )
  968. 			strText = Replace( strText, Chr(250), "&uacute;" )
  969. 			strText = Replace( strText, Chr(251), "&ucirc;"  )
  970. 			strText = Replace( strText, Chr(252), "&uuml;"   )
  971. 			strText = Replace( strText, Chr(253), "&yacute;" )
  972. 			strText = Replace( strText, Chr(254), "&thorn;"  )
  973. 			strText = Replace( strText, Chr(255), "&yuml;"   )
  974. 		Case Else
  975. 			MsgBox "Unexpected Code Page: " & myCodePage _
  976. 			     & vbCrLf & vbCrLf _
  977. 			     & "To have it added to the list of correctly translated code pages, notify the author of this script." _
  978. 			     & vbCrLf & vbCrLf _
  979. 			     & "Until this code page is added to the script, accented letters will be displayed incorrectly in the HTML output."
  980. 	End Select
  981. 	Escape  = strText
  982. End Function
  983.  
  984.  
  985.  
  986. Function FileVer( myCommand )
  987. 	Dim objFSO, strExt, strFile, strFullPath, wshShell
  988. 	FileVer = "-1" ' Default when file or command not found
  989. 	strFile = UCase( myCommand )
  990. 	If strFile = "PRINTBRM" Then
  991. 		Set wshShell = CreateObject( "WScript.Shell" )
  992. 		strFullPath = wshShell.ExpandEnvironmentStrings( "%windir%\system32\spool\tools\PRINTBRM.EXE" )
  993. 		Set wshShell = Nothing
  994. 	Else
  995. 		strFullPath = Which( strFile )
  996. 	End If
  997. 	If strFullPath <> "" Then
  998. 		Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  999. 		FileVer = objFSO.GetFileVersion( strFullPath )
  1000. 		Set objFSO = Nothing
  1001. 	End If
  1002. End Function
  1003.  
  1004.  
  1005.  
  1006. Function GetAddedCmdHelp( myCommand )
  1007. ' Get the short help text for the specified command and remove some unwanted characters
  1008. 	Dim objExec, objFile, objFSO, objRE, strCommand, strCommandLine, strFile, strHelp, strOutput, wshShell
  1009. 	strCommand = Trim( UCase( myCommand ) )
  1010. 	Set wshShell = CreateObject( "Wscript.Shell" )
  1011. 	' Build the command line to extract the help text
  1012. 	strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": " & strCommand & "&" & strCommand & " /? 2>&1)"
  1013. 	' Not all commands use the same standard for getting their help text
  1014. 	If strCommand = "AUTORUNSC" Then
  1015. 		' Use MORE to remove stray BOM codes in the middle of the help text
  1016. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": " & strCommand & "&" & strCommand & " /? 2>NUL | MORE)"
  1017. 	End If
  1018. 	If strCommand = "HEX2DEC" Or strCommand = "IFMEMBER" Then
  1019. 		' These commands show an error message if /? is used, they are best called without any arguments
  1020. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": " & strCommand & "&" & strCommand & " 2>&1)"
  1021. 	End If
  1022. 	If strCommand = "PRINTBRM" Then
  1023. 		' PRINTBRM is not in the PATH
  1024. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": PRINTBRM&""" & wshShell.ExpandEnvironmentStrings( "%windir%\system32\spool\tools\PRINTBRM.EXE" ) & """ | FIND /V "":"")"
  1025. 	End If
  1026. 	If strCommand = "REGISTER-CIMPROVIDER" Then
  1027. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": REGISTER-CIMPROVIDER&REGISTER-CIMPROVIDER -help 2>&1)"
  1028. 	End If
  1029. 	If strCommand = "RPCPING" Then
  1030. 		' Use MORE to remove ASCII null characters
  1031. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": RPCPING&RPCPING /? 2>&1 | MORE)"
  1032. 	End If
  1033. 	If strCommand = "SC" Then
  1034. 		' SC requires non-directed keyboard input, so we'll add a message to the title bar
  1035. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": SC - Press Enter to continue&SC /? 2>&1)"
  1036. 	End If
  1037. 	If strCommand = "SFC" Then
  1038. 		' SFC's output in Windows 8 is a mess, so we need temporary files and MORE to clean up its output
  1039. 		strFile = wshShell.ExpandEnvironmentStrings( "%Temp%\" & LCase( strCommand ) & ".txt" )
  1040. 		Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  1041. 		strCommandLine = "CMD /C (" & strCommand & " /? > """ & strFile & """ 2>&1)"
  1042. 		Set objExec = wshShell.Exec( strCommandLine )
  1043. 		objExec.Terminate
  1044. 		strCommandLine = "CMD /C (MORE < """ & strFile & """ > " & strFile & ".2)"
  1045. 		Set objExec = wshShell.Exec( strCommandLine )
  1046. 		objExec.Terminate
  1047. 		strCommandLine = "CMD /A /C (TYPE """ & strFile & ".2"")"
  1048. 	End If
  1049. 	If strCommand = "SUBINACL" Then
  1050. 		' SUBINACL's output is incomplete Unicode and poses quite a challenge to redirect and then read;
  1051. 		' so we first create an Unicode text file with 1 blank line, and then append SUBINACL's output
  1052. 		strFile = wshShell.ExpandEnvironmentStrings( "%Temp%\" & LCase( strCommand ) & ".txt" )
  1053. 		Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  1054. 		Set objFile  = objFSO.CreateTextFile( strFile, True, True )
  1055. 		objFile.WriteBlankLines 1
  1056. 		objFile.Close
  1057. 		strCommandLine = "CMD /C (VER | " & strCommand & " /help /full >> """ & strFile & """ 2>&1)"
  1058. 		Set objExec = wshShell.Exec( strCommandLine )
  1059. 		objExec.Terminate
  1060. 		Set objFile = objFSO.GetFile( strFile )
  1061. 		If objFile.Size < 2048 Then
  1062. 			Set objFile = Nothing
  1063. 			Set objFile = objFSO.CreateTextFile( strFile, True, True )
  1064. 			objFile.WriteBlankLines 1
  1065. 			objFile.Close
  1066. 			strCommandLine = "CMD /C (" & strCommand & " /? >> """ & strFile & """ 2>&1)"
  1067. 			Set objExec = wshShell.Exec( strCommandLine )
  1068. 			objExec.Terminate
  1069. 		End If
  1070. 		Set objFile = Nothing
  1071. 		strCommandLine = "CMD /A /C (TYPE """ & strFile & """)"
  1072. 	End If
  1073. 	' Remove ASCII null characters; trick by Austin France
  1074. 	' http://austinfrance.wordpress.com/2011/01/13/howto-vbscript-remove-chr0-null-from-a-string/
  1075. 	Set objRE = New RegExp
  1076. 	objRE.Global     = True
  1077. 	objRE.Pattern    = "[\0]"
  1078. 	objRE.IgnoreCase = False
  1079. 	strHelp          = ""
  1080. 	strOutput        = ""
  1081. 	Set objExec = wshShell.Exec( strCommandLine )
  1082. 	strOutput = objExec.StdOut.ReadAll
  1083. 	strHelp   = objRE.Replace( strOutput, "" )
  1084. 	objExec.Terminate
  1085. 	' Correct missing linefeed
  1086. 	If strCommand = "BITSADMIN" Then
  1087. 		strHelp = Replace( strHelp, "SetNotifyFlags/GETNOTIFYINTERFACE", "SetNotifyFlags" & vbCrLf & "/GETNOTIFYINTERFACE" )
  1088. 	End If
  1089. 	If strCommand = "DHCPLOC" Then
  1090. 		' Strip path from program name
  1091. 		objRE.Pattern    = "[\r\n][^\r\n]\\dhcploc\.exe \["
  1092. 		objRE.IgnoreCase = True
  1093. 		strHelp          = objRE.Replace( strHelp, "DHCPLOC.EXE [" )
  1094. 	End If
  1095. 	If strCommand = "FINDLINKS" Then
  1096. 		' Strip path from program name
  1097. 		objRE.Global     = False
  1098. 		objRE.IgnoreCase = True
  1099. 		objRE.Pattern    = ":(\s+)[A-Z]:\\([^\\]+\\)*FindLinks(\.exe)?" ' ":\1FindLinks"
  1100. 		' Remove path from command
  1101. 		strHelp = objRE.Replace( strHelp, ": FINDLINKS" )
  1102. 	End If
  1103. 	If strCommand = "SFC" Then
  1104. 		' Convert incorrect Unicode to ASCII
  1105. 		strHelp = ToASCII( strHelp )
  1106. 	End If
  1107. 	' Check if the command line returned an "unknown command" error
  1108. 	If strHelp = Replace( strUnknownCommand, "MY_DUMMY_UNKNOWN_COMMAND.EXE", strCommand ) Then
  1109. 		If blnDebug Then DebugDisplay SuperTrim( strHelp )
  1110. 		strHelp = ""
  1111. 	End If
  1112. 	' Clean up
  1113. 	Set objRE    = Nothing
  1114. 	Set objExec  = Nothing
  1115. 	Set wshShell = Nothing
  1116. 	' Return the result
  1117. 	GetAddedCmdHelp = strHelp
  1118. End Function
  1119.  
  1120.  
  1121.  
  1122. Function GetCmdHelp( myCommand )
  1123. ' Get the help text for the specified command
  1124. ' and format it to fit in the generated HTML page
  1125. 	Dim objExec, objRE1, objRE2, strCommand, strCommandLine, strHelp, wshShell
  1126. 	strCommand = Trim( UCase( myCommand ) )
  1127. 	Set wshShell = CreateObject( "Wscript.Shell" )
  1128. 	' Check if there is any help available at all; if not, try <command> /? instead.
  1129. 	Set objRE1 = New RegExp
  1130. 	objRE1.Global     = True
  1131. 	objRE1.Pattern    = """" & strCommand & " /\?"""
  1132. 	objRE1.IgnoreCase = True
  1133. 	' Remove ASCII null characters; trick by Austin France
  1134. 	' http://austinfrance.wordpress.com/2011/01/13/howto-vbscript-remove-chr0-null-from-a-string/
  1135. 	Set objRE2 = New RegExp
  1136. 	objRE2.Global     = True
  1137. 	objRE2.Pattern    = "[\0]"
  1138. 	objRE2.IgnoreCase = False
  1139. 	' Build the command line to extract the help text
  1140. 	strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": " & strCommand & "&HELP " & strCommand & ")"
  1141. 	If strCommand = "SC" Then
  1142. 		strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": SC - Press Enter to continue&HELP SC)"
  1143. 		If Not blnQuiet Then
  1144. 			WScript.Echo vbCrLf & "AllHelp " & strScriptVer & ":" & vbCrLf & vbCrLf & "Press Enter to continue . . ."
  1145. 		End If
  1146. 	End If
  1147. 	Set objExec = wshShell.Exec( strCommandLine )
  1148. 	strHelp = objRE2.Replace( objExec.StdOut.ReadAll, "" )
  1149. 	objExec.Terminate
  1150. 	' Check if there is any help available at all; if not, try <command> /? instead.
  1151. 	If objRE1.Test( strHelp ) Then strHelp = GetAddedCmdHelp( strCommand )
  1152. 	' Clean up
  1153. 	Set objRE1   = Nothing
  1154. 	Set objRE2   = Nothing
  1155. 	Set objExec  = Nothing
  1156. 	Set wshShell = Nothing
  1157. 	' Return the result
  1158. 	GetCmdHelp = strHelp
  1159. End Function
  1160.  
  1161.  
  1162.  
  1163. Function GetCodePage( )
  1164. 	Dim arrCodePage, idxCodePage, numCodePage, objExec, strCodePage, wshShell
  1165. 	numCodePage = 0
  1166. 	On Error Resume Next
  1167. 	Set wshShell = CreateObject( "Wscript.Shell" )
  1168. 	Set objExec  = wshShell.Exec( "CMD.EXE /C CHCP" )
  1169. 	strCodePage = objExec.StdOut.ReadAll
  1170. 	arrCodePage = Split( strCodePage, " " )
  1171. 	If IsArray( arrCodePage ) Then
  1172. 		idxCodePage = UBound( arrCodePage )
  1173. 		numCodePage = CInt( arrCodePage( idxCodePage ) )
  1174. 	End If
  1175. 	objExec.Terminate
  1176. 	Set objExec  = Nothing
  1177. 	Set wshShell = Nothing
  1178. 	On Error Goto 0
  1179. 	GetCodePage = numCodePage
  1180. End Function
  1181.  
  1182.  
  1183.  
  1184. Function GetCommandError( )
  1185. ' Get the OS' message text for non-existing commands
  1186. 	Dim objExec, strCommandLine, strError, wshShell
  1187. 	strCommandLine = "CMD.EXE /A /C (TITLE AllHelp " & strScriptVer & ": TESTING&MY_DUMMY_UNKNOWN_COMMAND.EXE /? 2>&1)"
  1188. 	Set wshShell = CreateObject( "Wscript.Shell" )
  1189. 	Set objExec  = wshShell.Exec( strCommandLine )
  1190. 	strError = objExec.StdOut.ReadAll
  1191. 	objExec.Terminate
  1192. 	Set objExec  = Nothing
  1193. 	Set wshShell = Nothing
  1194. 	GetCommandError = strError
  1195. End Function
  1196.  
  1197.  
  1198.  
  1199. Function GetFileDescription( myCommand )
  1200. ' Find a command file and get its file description
  1201. 	Dim objFolder, objFSO, objItem, objShell, strDescription, strFile, strFolder, wshShell
  1202. 	GetFileDescription = ""
  1203. 	' First check if the file description is available in the dictionary we created for %windir%\system32\*.exe files
  1204. 	If Not dicSystemFiles.Item( UCase( myCommand ) & ".EXE" ) = "" Then
  1205. 		GetFileDescription = dicSystemFiles.Item( UCase( myCommand ) & ".EXE" )
  1206. 	Else
  1207. 		If Left( strNumVer, InStr( strNumVer, "." ) - 1 ) > 5 Then ' Vista and later
  1208. 			Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  1209. 			' Get th fully qualified path for the command
  1210. 			If myCommand = "PRINTBMR" Then
  1211. 				Set wshShell = CreateObject( "Wscript.Shell" )
  1212. 				strFile = wshShell.ExpandEnvironmentStrings( "%windir%\system32\spool\tools\PRINTBMR.EXE" )
  1213. 				Set wshShell = Nothing
  1214. 			Else
  1215. 				strFile = Which( myCommand )
  1216. 			End If
  1217. 			' Get its file description (this is SLOW for directories with many files, i.e. %windir%\system32)
  1218. 			If objFSO.FileExists( strFile ) Then
  1219. 				' Based on code by Allen on the KiXtart forum:
  1220. 				' http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=160880
  1221. 				strFolder = objFSO.GetParentFolderName( strFile )
  1222. 				Set objShell  = CreateObject( "Shell.Application" )
  1223. 				Set objFolder = objShell.NameSpace( strFolder )
  1224. 				For Each objItem In objFolder.Items
  1225. 					If UCase( objItem.Name ) = UCase( myCommand & ".EXE" ) Then
  1226. 						strDescription = objFolder.GetDetailsOf( objItem, 34 ) ' Vista and later
  1227. 						strDescription = SuperTrim( strDescription )
  1228. 						GetFileDescription = strDescription
  1229. 					End If
  1230. 				Next
  1231. 				Set objFolder = Nothing
  1232. 				Set objShell  = Nothing
  1233. 			End If
  1234. 			Set objFSO = Nothing
  1235. 		End if
  1236. 	End If
  1237. End Function
  1238.  
  1239.  
  1240.  
  1241. Function GetOSLanguage( myLocale )
  1242. ' Get the description for the OS language/locale number
  1243. 	Dim i, arrOSLanguage(20490)
  1244. 	For i = 0 To 20490
  1245. 		arrOSLanguage(i) = ""
  1246. 	Next
  1247. 	arrOSLanguage(1)     = "Arabic"
  1248. 	arrOSLanguage(4)     = "Chinese (Simplified) - China"
  1249. 	arrOSLanguage(9)     = "English"
  1250. 	arrOSLanguage(1025)  = "Arabic - Saudi Arabia"
  1251. 	arrOSLanguage(1026)  = "Bulgarian"
  1252. 	arrOSLanguage(1027)  = "Catalan"
  1253. 	arrOSLanguage(1028)  = "Chinese (Traditional) - Taiwan"
  1254. 	arrOSLanguage(1029)  = "Czech"
  1255. 	arrOSLanguage(1030)  = "Danish"
  1256. 	arrOSLanguage(1031)  = "German - Germany"
  1257. 	arrOSLanguage(1032)  = "Greek"
  1258. 	arrOSLanguage(1033)  = "English - United States"
  1259. 	arrOSLanguage(1034)  = "Spanish - Traditional Sort"
  1260. 	arrOSLanguage(1035)  = "Finnish"
  1261. 	arrOSLanguage(1036)  = "French - France"
  1262. 	arrOSLanguage(1037)  = "Hebrew"
  1263. 	arrOSLanguage(1038)  = "Hungarian"
  1264. 	arrOSLanguage(1039)  = "Icelandic"
  1265. 	arrOSLanguage(1040)  = "Italian - Italy"
  1266. 	arrOSLanguage(1041)  = "Japanese"
  1267. 	arrOSLanguage(1042)  = "Korean"
  1268. 	arrOSLanguage(1043)  = "Dutch - Netherlands"
  1269. 	arrOSLanguage(1044)  = "Norwegian - Bokmal"
  1270. 	arrOSLanguage(1045)  = "Polish"
  1271. 	arrOSLanguage(1046)  = "Portuguese - Brazil"
  1272. 	arrOSLanguage(1047)  = "Rhaeto-Romanic"
  1273. 	arrOSLanguage(1048)  = "Romanian"
  1274. 	arrOSLanguage(1049)  = "Russian"
  1275. 	arrOSLanguage(1050)  = "Croatian"
  1276. 	arrOSLanguage(1051)  = "Slovak"
  1277. 	arrOSLanguage(1052)  = "Albanian"
  1278. 	arrOSLanguage(1053)  = "Swedish"
  1279. 	arrOSLanguage(1054)  = "Thai"
  1280. 	arrOSLanguage(1055)  = "Turkish"
  1281. 	arrOSLanguage(1056)  = "Urdu"
  1282. 	arrOSLanguage(1057)  = "Indonesian"
  1283. 	arrOSLanguage(1058)  = "Ukrainian"
  1284. 	arrOSLanguage(1059)  = "Belarusian"
  1285. 	arrOSLanguage(1060)  = "Slovenian"
  1286. 	arrOSLanguage(1061)  = "Estonian"
  1287. 	arrOSLanguage(1062)  = "Latvian"
  1288. 	arrOSLanguage(1063)  = "Lithuanian"
  1289. 	arrOSLanguage(1065)  = "Persian"
  1290. 	arrOSLanguage(1066)  = "Vietnamese"
  1291. 	arrOSLanguage(1069)  = "Basque"
  1292. 	arrOSLanguage(1070)  = "Serbian"
  1293. 	arrOSLanguage(1071)  = "Macedonian (FYROM)"
  1294. 	arrOSLanguage(1072)  = "Sutu"
  1295. 	arrOSLanguage(1073)  = "Tsonga"
  1296. 	arrOSLanguage(1074)  = "Tswana"
  1297. 	arrOSLanguage(1076)  = "Xhosa"
  1298. 	arrOSLanguage(1077)  = "Zulu"
  1299. 	arrOSLanguage(1078)  = "Afrikaans"
  1300. 	arrOSLanguage(1080)  = "Faeroese"
  1301. 	arrOSLanguage(1081)  = "Hindi"
  1302. 	arrOSLanguage(1082)  = "Maltese"
  1303. 	arrOSLanguage(1084)  = "Gaelic"
  1304. 	arrOSLanguage(1085)  = "Yiddish"
  1305. 	arrOSLanguage(1086)  = "Malay - Malaysia"
  1306. 	arrOSLanguage(2049)  = "Arabic - Iraq"
  1307. 	arrOSLanguage(2052)  = "Chinese (Simplified) - PRC"
  1308. 	arrOSLanguage(2055)  = "German - Switzerland"
  1309. 	arrOSLanguage(2057)  = "English - United Kingdom"
  1310. 	arrOSLanguage(2058)  = "Spanish - Mexico"
  1311. 	arrOSLanguage(2060)  = "French - Belgium"
  1312. 	arrOSLanguage(2064)  = "Italian - Switzerland"
  1313. 	arrOSLanguage(2067)  = "Dutch - Belgium"
  1314. 	arrOSLanguage(2068)  = "Norwegian - Nynorsk"
  1315. 	arrOSLanguage(2070)  = "Portuguese - Portugal"
  1316. 	arrOSLanguage(2072)  = "Romanian - Moldova"
  1317. 	arrOSLanguage(2073)  = "Russian - Moldova"
  1318. 	arrOSLanguage(2074)  = "Serbian - Latin"
  1319. 	arrOSLanguage(2077)  = "Swedish - Finland"
  1320. 	arrOSLanguage(3073)  = "Arabic - Egypt"
  1321. 	arrOSLanguage(3076)  = "Chinese (Traditional) - Hong Kong SAR"
  1322. 	arrOSLanguage(3079)  = "German - Austria"
  1323. 	arrOSLanguage(3081)  = "English - Australia"
  1324. 	arrOSLanguage(3082)  = "Spanish - International Sort"
  1325. 	arrOSLanguage(3084)  = "French - Canada"
  1326. 	arrOSLanguage(3098)  = "Serbian - Cyrillic"
  1327. 	arrOSLanguage(4097)  = "Arabic - Libya"
  1328. 	arrOSLanguage(4100)  = "Chinese (Simplified) - Singapore"
  1329. 	arrOSLanguage(4103)  = "German - Luxembourg"
  1330. 	arrOSLanguage(4105)  = "English - Canada"
  1331. 	arrOSLanguage(4106)  = "Spanish - Guatemala"
  1332. 	arrOSLanguage(4108)  = "French - Switzerland"
  1333. 	arrOSLanguage(5121)  = "Arabic - Algeria"
  1334. 	arrOSLanguage(5127)  = "German - Liechtenstein"
  1335. 	arrOSLanguage(5129)  = "English - New Zealand"
  1336. 	arrOSLanguage(5130)  = "Spanish - Costa Rica"
  1337. 	arrOSLanguage(5132)  = "French - Luxembourg"
  1338. 	arrOSLanguage(6145)  = "Arabic - Morocco"
  1339. 	arrOSLanguage(6153)  = "English - Ireland"
  1340. 	arrOSLanguage(6154)  = "Spanish - Panama"
  1341. 	arrOSLanguage(7169)  = "Arabic - Tunisia"
  1342. 	arrOSLanguage(7177)  = "English - South Africa"
  1343. 	arrOSLanguage(7178)  = "Spanish - Dominican Republic"
  1344. 	arrOSLanguage(8193)  = "Arabic - Oman"
  1345. 	arrOSLanguage(8201)  = "English - Jamaica"
  1346. 	arrOSLanguage(8202)  = "Spanish - Venezuela"
  1347. 	arrOSLanguage(9217)  = "Arabic - Yemen"
  1348. 	arrOSLanguage(9226)  = "Spanish - Colombia"
  1349. 	arrOSLanguage(10241) = "Arabic - Syria"
  1350. 	arrOSLanguage(10249) = "English - Belize"
  1351. 	arrOSLanguage(10250) = "Spanish - Peru"
  1352. 	arrOSLanguage(11265) = "Arabic - Jordan"
  1353. 	arrOSLanguage(11273) = "English - Trinidad"
  1354. 	arrOSLanguage(11274) = "Spanish - Argentina"
  1355. 	arrOSLanguage(12289) = "Arabic - Lebanon"
  1356. 	arrOSLanguage(12298) = "Spanish - Ecuador"
  1357. 	arrOSLanguage(13313) = "Arabic - Kuwait"
  1358. 	arrOSLanguage(13322) = "Spanish - Chile"
  1359. 	arrOSLanguage(14337) = "Arabic - U.A.E."
  1360. 	arrOSLanguage(14346) = "Spanish - Uruguay"
  1361. 	arrOSLanguage(15361) = "Arabic - Bahrain"
  1362. 	arrOSLanguage(15370) = "Spanish - Paraguay"
  1363. 	arrOSLanguage(16385) = "Arabic - Qatar"
  1364. 	arrOSLanguage(16394) = "Spanish - Bolivia"
  1365. 	arrOSLanguage(17418) = "Spanish - El Salvador"
  1366. 	arrOSLanguage(18442) = "Spanish - Honduras"
  1367. 	arrOSLanguage(19466) = "Spanish - Nicaragua"
  1368. 	arrOSLanguage(20490) = "Spanish - Puerto Rico"
  1369. 	If Trim( myLocale ) = "" Then
  1370. 		GetOSLanguage = arrOSLanguage( GetLocale( ) )
  1371. 	Else
  1372. 		GetOSLanguage = arrOSLanguage( myLocale )
  1373. 	End If
  1374. End Function
  1375.  
  1376.  
  1377.  
  1378. Sub GetSystemFileDescriptions( )
  1379. ' List file names and descriptions for all *.exe files in %windir%\system32
  1380. 	Dim objFolder, objFSO, objItem, objShell, strDescription, strFile, strFolder, wshShell
  1381. 	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  1382. 	Set wshShell = CreateObject( "Wscript.Shell" )
  1383. 	strFolder = objFSO.GetParentFolderName( strFile )
  1384. 	Set objShell  = CreateObject( "Shell.Application" )
  1385. 	Set objFolder = objShell.NameSpace( wshShell.ExpandEnvironmentStrings( "%windir%\system32" ) )
  1386. 	For Each objItem In objFolder.Items
  1387. 		strFile = UCase( objItem.Name )
  1388. 		If UCase( objFSO.GetExtensionName( strFile ) ) = "EXE" Then
  1389. 			strDescription = objFolder.GetDetailsOf( objItem, 34 ) ' Vista and later
  1390. 			strDescription = SuperTrim( strDescription )
  1391. 			dicSystemFiles.Item( objItem.Name ) = strDescription
  1392. 		End If
  1393. 	Next
  1394. 	Set objFolder = Nothing
  1395. 	Set objShell  = Nothing
  1396. 	Set wshShell = Nothing
  1397. 	Set objFSO   = Nothing
  1398. End Sub
  1399.  
  1400.  
  1401.  
  1402. Function HTMLFoot( )
  1403. ' Create the foot for the HTML page
  1404. 	HTMLFoot = "<p>&nbsp;</p>" & vbCrLf & vbCrLf _
  1405. 	         & "<div style=""text-align: center;"">" & vbCrLf _
  1406. 	         & "<p>This HTML help file was generated by <a href=""http://www.robvanderwoude.com/wshexamples.php?fc=A#AllHelp"">AllHelp.vbs</a>, Version " & strScriptVer & "<br>" & vbCrLf _
  1407. 	         & "Written by Rob van der Woude<br>" & vbCrLf _
  1408. 	         & "<a href=""http://www.robvanderwoude.com"">http://www.robvanderwoude.com</a></p>" & vbCrLf _
  1409. 	         & "</div>" & vbCrLf & vbCrLf _
  1410. 	         & "</div>" & vbCrLf & vbCrLf _
  1411. 	         & "</div>" & vbCrLf & vbCrLf _
  1412. 	         & "<script type=""text/javascript"">" & vbCrLf _
  1413. 	         & "getDefaultAnchorColor( );" & vbCrLf _
  1414. 	         & "</script>" & vbCrLf & vbCrLf _
  1415. 	         & "</body>" & vbCrLf _
  1416. 	         & "</html>"
  1417. End Function
  1418.  
  1419.  
  1420.  
  1421. Function HTMLHead( )
  1422. ' Create the head for the HTML page
  1423. 	HTMLHead = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN"" ""http://www.w3.org/TR/html4/strict.dtd"">" & vbCrLf _
  1424.          & "<html>" & vbCrLf _
  1425.          & "<head>" & vbCrLf & vbCrLf _
  1426.          & "<title>Help for all " & strWinVer & " " & strCSDVer & " commands</title>" & vbCrLf & vbCrLf _
  1427.          & "<meta name=""generator"" content=""AllHelp.vbs, Version " & strScriptVer & ", by Rob van der Woude, www.robvanderwoude.com"">" & vbCrLf _
  1428.          & "<style type=""text/css"">" & vbCrLf _
  1429.          & "a, a.visited" & vbCrLf _
  1430.          & "{" & vbCrLf _
  1431.          & vbTab & "color: blue;" & vbCrLf _
  1432.          & "}" & vbCrLf & vbCrLf _
  1433.          & "td.Command" & vbCrLf _
  1434.          & "{" & vbCrLf _
  1435.          & vbTab & "vertical-align: top;" & vbCrLf _
  1436.          & vbTab & "padding-left: 10px;"  & vbCrLf _
  1437.          & vbTab & "padding-right: 5px;"  & vbCrLf _
  1438.          & vbTab & "font-weight: bold;"   & vbCrLf _
  1439.          & vbTab & "white-space: nowrap;" & vbCrLf _
  1440.          & "}" & vbCrLf & vbCrLf _
  1441.          & "th" & vbCrLf _
  1442.          & "{" & vbCrLf _
  1443.          & vbTab & "vertical-align: top;" & vbCrLf _
  1444.          & "}" & vbCrLf & vbCrLf _
  1445.          & "table.Alphabet" & vbCrLf _
  1446.          & "{" & vbCrLf _
  1447.          & vbTab & "border: 2px solid blue;" & vbCrLf _
  1448.          & vbTab & "margin: 0 auto 0 auto;"  & vbCrLf _
  1449.          & vbTab & "text-align: center;"     & vbCrLf _
  1450.          & vbTab & "vertical-align: middle;" & vbCrLf _
  1451.          & vbTab & "width: 100%;"            & vbCrLf _
  1452.          & "}" & vbCrLf & vbCrLf _
  1453.          & "table.Alphabet th" & vbCrLf _
  1454.          & "{" & vbCrLf _
  1455.          & vbTab & "padding: 5px;" & vbCrLf _
  1456.          & vbTab & "width: 4%;"    & vbCrLf _
  1457.          & "}" & vbCrLf & vbCrLf _
  1458.          & "table.List" & vbCrLf _
  1459.          & "{" & vbCrLf _
  1460.          & vbTab & "margin: 0 auto 0 auto;" & vbCrLf _
  1461.          & vbTab & "width: 100%;"           & vbCrLf _
  1462.          & "}" & vbCrLf & vbCrLf _
  1463.          & "table.List th" & vbCrLf _
  1464.          & "{" & vbCrLf _
  1465.          & vbTab & "background-color: blue;" & vbCrLf _
  1466.          & vbTab & "color: white;"           & vbCrLf _
  1467.          & vbTab & "font-size: 120%;"        & vbCrLf _
  1468.          & vbTab & "font-weight: bold;"      & vbCrLf _
  1469.          & vbTab & "padding-left: 10px;"     & vbCrLf _
  1470.          & "}" & vbCrLf & vbCrLf _
  1471.          & "pre" & vbCrLf _
  1472.          & "{"   & vbCrLf _
  1473.          & vbTab & "white-space: pre-wrap;" & vbCrLf _
  1474.          & "}" & vbCrLf _
  1475.          & "</style>" & vbCrLf & vbCrLf _
  1476.          & "<script type=""text/javascript"">" & vbCrLf _
  1477.          & "var defaultColor;" & vbCrLf _
  1478.          & "function getDefaultAnchorColor( ) {" & vbCrLf _
  1479.          & vbTab & "var addchr = document.getElementsByClassName( 'AdditionalChar' );" & vbCrLf _
  1480.          & vbTab & "for ( var i = 0; i < addchr.length; i++ ) {"   & vbCrLf _
  1481.          & vbTab & vbTab & "defaultColor = addchr[i].style.color;" & vbCrLf _
  1482.          & vbTab & "}" & vbCrLf _
  1483.          & "}" & vbCrLf _
  1484.          & "function toggleVisibility( ) {" & vbCrLf _
  1485.          & vbTab & "var button = document.getElementById( 'WinOnlyButton' );"          & vbCrLf _
  1486.          & vbTab & "var addchr = document.getElementsByClassName( 'AdditionalChar' );" & vbCrLf _
  1487.          & vbTab & "var addcmd = document.getElementsByClassName( 'Additional' );"     & vbCrLf _
  1488.          & vbTab & "var addhlp = document.getElementsByClassName( 'AdditionalHelp' );" & vbCrLf _
  1489.          & vbTab & "if ( button.value == 'Windows Help Only' ) {" & vbCrLf _
  1490.          & vbTab & vbTab & "button.value = 'All Commands';"       & vbCrLf _
  1491.          & vbTab & vbTab & "for ( var i = 0; i < addchr.length; i++ ) {" & vbCrLf _
  1492.          & vbTab & vbTab & vbTab & "addchr[i].style.color = 'gray';"     & vbCrLf _
  1493.          & vbTab & vbTab & "}" & vbCrLf _
  1494.          & vbTab & vbTab & "for ( var i = 0; i < addchr.length; i++ ) {" & vbCrLf _
  1495.          & vbTab & vbTab & vbTab & "addchr[i].style.color = 'gray';"     & vbCrLf _
  1496.          & vbTab & vbTab & "}" & vbCrLf _
  1497.          & vbTab & vbTab & "for ( var i = 0; i < addcmd.length; i++ ) {" & vbCrLf _
  1498.          & vbTab & vbTab & vbTab & "addcmd[i].style.display = 'none';"   & vbCrLf _
  1499.          & vbTab & vbTab & "}" & vbCrLf _
  1500.          & vbTab & vbTab & "for( var i = 0; i < addhlp.length; i++ ) {"  & vbCrLf _
  1501.          & vbTab & vbTab & vbTab & "addhlp[i].style.display = 'none';"   & vbCrLf _
  1502.          & vbTab & vbTab & "}" & vbCrLf _
  1503.          & vbTab & "} else {"  & vbCrLf _
  1504.          & vbTab & vbTab & "button.value = 'Windows Help Only'"            & vbCrLf _
  1505.          & vbTab & vbTab & "for( var i = 0; i < addchr.length; i++ ) {"    & vbCrLf _
  1506.          & vbTab & vbTab & vbTab & "addchr[i].style.color = defaultColor;" & vbCrLf _
  1507.          & vbTab & vbTab & "}" & vbCrLf _
  1508.          & vbTab & vbTab & "for( var i = 0; i < addcmd.length; i++ ) {"     & vbCrLf _
  1509.          & vbTab & vbTab & vbTab & "addcmd[i].style.display = 'table-row';" & vbCrLf _
  1510.          & vbTab & vbTab & "}" & vbCrLf _
  1511.          & vbTab & vbTab & "for( var i = 0; i < addhlp.length; i++ ) {" & vbCrLf _
  1512.          & vbTab & vbTab & vbTab & "addhlp[i].style.display = 'block';" & vbCrLf _
  1513.          & vbTab & vbTab & "}" & vbCrLf _
  1514.          & vbTab & "}" & vbCrLf _
  1515.          & "}" & vbCrLf _
  1516.          & "</script>" & vbCrLf & vbCrLf _
  1517.          & "</head>"   & vbCrLf & vbCrLf _
  1518.          & "<body>"    & vbCrLf & vbCrLf _
  1519.          & "<div style=""text-align: center;"">" & vbCrLf _
  1520.          & "<h1>" & strWinVer & " " & Trim( strCSDVer ) & "</h1>" & vbCrLf _
  1521.          & "<h2>Version " & strNumVer & " (" & intBitsOS & " bits)</h2>" & vbCrLf _
  1522.          & "<h3>" & GetOSLanguage( strOSLocl ) & "</h3>" & vbCrLf _
  1523.          & "</div>"        & vbCrLf & vbCrLf _
  1524.          & "<p>&nbsp;</p>" & vbCrLf & vbCrLf _
  1525.          & "<div style=""width: 50em; text-align: center; margin: 0 auto 0 auto;"">" & vbCrLf & vbCrLf _
  1526.          & "<div style=""width: 50em; text-align: left;"">" & vbCrLf & vbCrLf
  1527. End Function
  1528.  
  1529.  
  1530.  
  1531. Function Max( num1, num2 )
  1532. ' Return the largest of 2 numbers
  1533. 	If num1 > num2 Then
  1534. 		Max = num1
  1535. 	Else
  1536. 		Max = num2
  1537. 	End If
  1538. End Function
  1539.  
  1540.  
  1541.  
  1542. Function Min( num1, num2 )
  1543. ' Return the smallest of 2 numbers
  1544. 	If num1 < num2 Then
  1545. 		Min = num1
  1546. 	Else
  1547. 		Min = num2
  1548. 	End If
  1549. End Function
  1550.  
  1551.  
  1552.  
  1553. Function SortDictionary( objDict, intSort )
  1554. ' Sort a Dictionary object
  1555. ' Code found on http://support.microsoft.com/kb/246067
  1556. 	Dim arrDict( )
  1557. 	Dim objKey
  1558. 	Dim strKey, strItem
  1559. 	Dim i,j,intCount
  1560.  
  1561. 	' Get the dictionary count
  1562. 	intCount = objDict.Count
  1563.  
  1564. 	' We need more than one item to warrant sorting
  1565. 	If intCount > 1 Then
  1566. 		' create an array to store dictionary information
  1567. 		ReDim arrDict( intCount, 2 )
  1568. 		i = 0
  1569. 		' Populate the string array
  1570. 		For Each objKey In objDict
  1571. 			arrDict( i, dictKey )  = CStr( objKey )
  1572. 			arrDict( i, dictItem ) = CStr( objDict( objKey ) )
  1573. 			i = i + 1
  1574. 		Next
  1575.  
  1576. 		' Perform a shell sort of the string array
  1577. 		For i = 0 to ( intCount - 2 )
  1578. 			For j = i to ( intCount - 1 )
  1579. 				If StrComp( arrDict( i, intSort ), arrDict( j, intSort ),vbTextCompare ) > 0 Then
  1580. 					strKey  = arrDict( i, dictKey )
  1581. 					strItem = arrDict( i, dictItem )
  1582. 					arrDict( i, dictKey )  = arrDict( j, dictKey )
  1583. 					arrDict( i, dictItem ) = arrDict( j, dictItem )
  1584. 					arrDict( j, dictKey )  = strKey
  1585. 					arrDict( j, dictItem ) = strItem
  1586. 				End If
  1587. 			Next
  1588. 		Next
  1589.  
  1590. 		' Erase the contents of the dictionary object
  1591. 		objDict.RemoveAll
  1592.  
  1593. 		' Repopulate the dictionary with the sorted information
  1594. 		For i = 0 to ( intCount - 1 )
  1595. 			objDict.Add arrDict( i, dictKey ), arrDict( i, dictItem )
  1596. 		Next
  1597. 	End If
  1598. End Function
  1599.  
  1600.  
  1601.  
  1602. Function SuperTrim( myText )
  1603. ' Remove linefeeds, tabs and multple spaces from a text
  1604. 	Dim strText
  1605. 	strText = Replace( myText,  vbCr,   " " )
  1606. 	strText = Replace( strText, vbLf,   " " )
  1607. 	strText = Replace( strText, vbCrLf, " " )
  1608. 	strText = Replace( strText, vbTab,  " " )
  1609. 	While ( InStr( strText, "  " ) )
  1610. 		strText = Replace( strText, "  ", " " )
  1611. 	Wend
  1612. 	SuperTrim = Trim( strText )
  1613. End Function
  1614.  
  1615.  
  1616.  
  1617. Sub Syntax
  1618. ' Display help and, optionally, debugging information
  1619. 	strMsg = strMsg & vbCrLf _
  1620. 	       & "AllHelp.vbs,  Version " & strScriptVer _
  1621. 	       & vbCrLf _
  1622. 	       & "Display help for ""all"" Windows commands, for" _
  1623. 	       & vbCrLf _
  1624. 	       & "the current Windows installion and language." _
  1625. 	       & vbCrLf & vbCrLf _
  1626. 	       & "Usage:  ALLHELP.VBS  [ ""outputfile"" ]  [ /Y ]  [ /WHO ]  [ /NOBATCH ]  [ /DEBUG ]" _
  1627. 	       & vbCrLf & vbCrLf _
  1628. 	       & "   or:  ALLHELP.VBS  /Q  [ /WHO ]  [ /INCLUDEBATCH ]  [ >  ""outputfile"" ]" _
  1629. 	       & vbCrLf & vbCrLf _
  1630. 	       & "Where:  ""outputfile""   is the fully qualified path of the HTML file to be" _
  1631. 	       & vbCrLf _
  1632. 	       & "                       created (default: ""allhelp.html"" in ""My Documents"")" _
  1633. 	       & vbCrLf _
  1634. 	       & "        /DEBUG         display DEBUGging information" _
  1635. 	       & vbCrLf _
  1636. 	       & "        /INCLUDEBATCH  include batch files (.bat and .cmd)" _
  1637. 	       & vbCrLf _
  1638. 	       & "        /Q             display only the HTML code, do not write to file" _
  1639. 	       & vbCrLf _
  1640. 	       & "        /WHO           show commands listed in Windows' Help Only" _
  1641. 	       & vbCrLf _
  1642. 	       & "        /Y             overwrite existing file (default: abort if exists)" _
  1643. 	       & vbCrLf & vbCrLf _
  1644. 	       & "Notes:  DISKPART and OPENFILES are protected by UAC; in order to retrieve" _
  1645. 	       & vbCrLf _
  1646. 	       & "        their help texts, run this script with elevated privileges." _
  1647. 	       & vbCrLf _
  1648. 	       & "        SC help requires keyboard input; its window title will ask you to" _
  1649. 	       & vbCrLf _
  1650. 	       & "        press Enter." _
  1651. 	       & vbCrLf _
  1652. 	       & "        The /Q switch can be used as a work-around to redirect the generated HTML" _
  1653. 	       & vbCrLf _
  1654. 	       & "        to a file in case of unexplained ""access denied"" errors (e.g. Windows 8.1)." _
  1655. 	       & vbCrLf & vbCrLf _
  1656. 	       & "Written by Rob van der Woude" _
  1657. 	       & vbCrLf _
  1658. 	       & "http://www.robvanderwoude.com"
  1659. 	WScript.Echo strMsg
  1660. 	WScript.Quit 1
  1661. End Sub
  1662.  
  1663.  
  1664.  
  1665. Function ToASCII( myString )
  1666. ' Strip special characters from SFC's output in Windows 8.1
  1667. 	Dim objRE, strText
  1668. 	strText = myString
  1669. 	Set objRE = New RegExp
  1670. 	objRE.Global  = True
  1671. 	objRE.Pattern = "^" & Chr(255) & Chr(254)
  1672. 	strText = objRE.Replace( strText, "" )
  1673. 	objRE.Pattern = "[\0]"
  1674. 	strText = objRE.Replace( strText, "" )
  1675. 	Set objRE = Nothing
  1676. 	ToASCII = strText
  1677. End Function
  1678.  
  1679.  
  1680.  
  1681. Function TrimCrLf( myString )
  1682. ' Remove unnnecessary linefeeds inside <pre></pre> blocks
  1683. 	Dim objMatches, objRE, strResult
  1684. 	strResult = Trim( myString )
  1685. 	If strResult = "" Then Exit Function
  1686. 	Set objRE = New RegExp
  1687. 	objRE.Global  = True
  1688. 	objRE.Pattern = "<pre>(" & vbCr & "|" & vbLf & ")+"
  1689. 	strResult     = objRE.Replace( strResult, "<pre>" )
  1690. 	objRE.Pattern = "(" & vbCr & "|" & vbLf & ")+</pre>"
  1691. 	strResult     = objRE.Replace( strResult, "</pre>" )
  1692. 	Set objRE = Nothing
  1693. 	strResult = Replace( strResult, vbCr & vbCrLf, vbCrLf )
  1694. 	TrimCrLf = strResult
  1695. End Function
  1696.  
  1697.  
  1698.  
  1699. Function Which( myCommand )
  1700. ' Get the fully qualified path to a command file
  1701. 	Dim arrPath, arrPathExt
  1702. 	Dim i, j
  1703. 	Dim objFSO, objRE, wshShell
  1704. 	Dim strComSpec, strPath, strPathExt, strTestPath
  1705. 	Which = ""
  1706. 	Set wshShell = CreateObject( "WScript.Shell" )
  1707. 	' Read the PATH and PATHEXT variables, and store their values in arrays; the current directory is prepended to the PATH first
  1708. 	strPath    = wshShell.CurrentDirectory & ";" & wshShell.ExpandEnvironmentStrings( "%PATH%" )
  1709. 	strPathExt = wshShell.ExpandEnvironmentStrings( "%PATHEXT%" )
  1710. 	If blnIgnoreBatch Then
  1711. 		' Remove .BAT and .CMD from %PATHEXT% to avoid listing batch files
  1712. 		Set objRE = New RegExp
  1713. 		objRE.Global     = True
  1714. 		objRE.IgnoreCase = True
  1715. 		objRE.Pattern    = "(\.bat|\.cmd)"
  1716. 		strPathExt = objRE.Replace( strPathExt, "" )
  1717. 		objRE.Pattern = "(^;|;$)"
  1718. 		strPathExt = objRE.Replace( strPathExt, "" )
  1719. 		objRE.Pattern = ";+"
  1720. 		strPathExt = objRE.Replace( strPathExt, ";" )
  1721. 		Set objRE = Nothing
  1722. 	End If
  1723. 	arrPath    = Split( strPath,    ";" )
  1724. 	arrPathExt = Split( strPathExt, ";" )
  1725. 	' But first let's check for INTERNAL commands
  1726. 	If arrIntCmd.Contains( UCase( myCommand ) ) Then
  1727. 		' Abort at the first match, return the path to the command processor
  1728. 		Which = wshShell.ExpandEnvironmentStrings( "%COMSPEC%" ) ' & " /C " & arrIntCmd(i)
  1729. 		Exit Function
  1730. 	End If
  1731. 	' Clean up
  1732. 	Set wshShell = Nothing
  1733. 	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  1734.  
  1735. 	' Use list of valid extensions from PATHEXT
  1736. 	For i = 0 To UBound( arrPathExt )
  1737. 		' Search the PATH
  1738. 		For j = 0 To UBound( arrPath )
  1739. 			' Skip empty directory values, caused by the PATH variable being terminated with a semicolon
  1740. 			If arrPath(j) <> "" Then
  1741. 				' Build a fully qualified path of the file to test for
  1742. 				strTestPath = objFSO.BuildPath( arrPath(j), myCommand & arrPathExt(i) )
  1743. 				' Check if that file exists
  1744. 				If objFSO.FileExists( strTestPath ) Then
  1745. 					' Abort at the first match
  1746. 					Which = objFSO.GetAbsolutePathName( strTestPath )
  1747. 					Set objFSO = Nothing
  1748. 					Exit Function
  1749. 				End If
  1750. 			End If
  1751. 		Next
  1752. 	Next
  1753. 	Set objFSO = Nothing
  1754. End Function
  1755.