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

page last uploaded: 2015-12-04, 16:51