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

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