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

page last uploaded: 2017-04-06, 13:33