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