Option Explicit Dim arrHelp( ) Dim blnDebug, blnOverwrite Dim i, intValidArgs Dim colItems, objExec, objHTMLFile, objFolder Dim objFolderItem, objFSO, objItem, objMatches Dim objRE, objShell, objWMISvc, wshShell Dim strCmd, strCSDVer, strFile, strHelp1, strHelp2 Dim strHelpAll, strHTML, strMsg, strNumVer, strOSLocl Dim strPattern, strScriptVer, strWinVer Const MY_DOCUMENTS = &H5 strMsg = "" strScriptVer = "1.01" intValidArgs = 0 blnDebug = False blnOverwrite = False Set objFSO = CreateObject( "Scripting.FileSystemObject" ) With WScript.Arguments If .Named.Exists( "DEBUG" ) Then blnDebug = True intValidArgs = intValidArgs + 1 If blnDebug Then strMsg = strMsg & "Debugging ON" & vbCrLf & vbCrLf End If End If If .Named.Exists( "Y" ) Then blnOverwrite = True intValidArgs = intValidArgs + 1 If blnDebug Then strMsg = strMsg & "File overwrite ON" & vbCrLf & vbCrLf End If Else If blnDebug Then strMsg = strMsg & "File overwrite OFF" & vbCrLf & vbCrLf End If End If If .Unnamed.Count = 1 Then strFile = .Unnamed(0) intValidArgs = intValidArgs + 1 If blnDebug Then strMsg = strMsg & "Output file: " & strFile & vbCrLf & vbCrLf End If Else Set objShell = CreateObject( "Shell.Application" ) Set objFolder = objShell.Namespace( MY_DOCUMENTS ) Set objFolderItem = objFolder.Self strFile = objFSO.BuildPath( objFolderItem.Path, "allhelp.html" ) If blnDebug Then strMsg = strMsg & "Output file: " & strFile & vbCrLf & vbCrLf End If Set objFolderItem = Nothing Set objFolder = Nothing Set objShell = Nothing End If If objFSO.FileExists( strFile ) And Not blnOverwrite Then If blnDebug Then strMsg = strMsg & "ERROR: The specified output file exists and file overwrite is OFF" & vbCrLf & vbCrLf End If Syntax End If If objFSO.FolderExists( strFile ) Then If blnDebug Then strMsg = strMsg & "ERROR: A folder with the name of the specified output file exists" & vbCrLf & vbCrLf End If Syntax End If If Not objFSO.FolderExists( objFSO.GetParentFolderName( strFile ) ) Then If blnDebug Then strMsg = strMsg & "ERROR: The parent folder for the specified output file does not exists" & vbCrLf & vbCrLf End If Syntax End If If intValidArgs <> .Count Then If blnDebug Then strMsg = strMsg & "ERROR: Invalid command line arguments" & vbCrLf & vbCrLf End If Syntax End If End With ' Get the OS version Set objWMISvc = GetObject( "winmgmts://./root/cimv2" ) Set colItems = objWMISvc.ExecQuery( "SELECT * FROM Win32_OperatingSystem", , 48 ) For Each objItem in colItems strWinVer = objItem.Caption strCSDVer = objItem.CSDVersion strOSLocl = objItem.OSLanguage strNumVer = objItem.Version Next Set colItems = Nothing Set objWMISvc = Nothing ' Create the head strHTML = "" & vbCrLf _ & "" & vbCrLf & "" & vbCrLf & vbCrLf _ & "Help for all " & strWinVer & " " & strCSDVer _ & " commands" & vbCrLf & vbCrLf _ & "" & vbCrLf _ & ""& vbCrLf & vbCrLf & "" & vbCrLf _ & vbCrLf & "" & vbCrLf & vbCrLf & "
" _ & vbCrLf & "

" & strWinVer & " " & Trim( strCSDVer ) & "

" _ & vbCrLf & "

Version " & strNumVer & "

" & vbCrLf _ & "

" & GetOSLanguage( strOSLocl ) & "

" & vbCrLf _ & "
" & vbCrLf & vbCrLf & "" & vbCrLf ' Fill the index table Set wshShell = CreateObject( "WScript.Shell" ) Set objExec = wshShell.Exec( "HELP" ) strHelpAll = objExec.StdOut.ReadAll objExec.Terminate Set objExec = Nothing Set objRE = New RegExp objRE.Global = True objRE.IgnoreCase = False objRE.Pattern = "(^|[\n\r])[A-Z]+ +([^\n\r]+)(\r\n +([^\n\r]+))*" Set objMatches = objRE.Execute( strHelpAll ) For i = 0 To objMatches.Count - 1 strHelp1 = Mid( objMatches.Item(i), 2, InStr( objMatches.Item(i), " " ) - 2 ) strHelp2 = Mid( objMatches.Item(i), InStr( objMatches.Item(i), " " ) ) strHelp2 = Replace( Trim( strHelp2 ), vbCrLf, " " ) Do Until InStr( strHelp2, " " ) = 0 strHelp2 = Replace( strHelp2, " ", " " ) Loop strHTML = strHTML & "" & vbCrLf _ & " " & vbCrLf & " " & vbCrLf & "" & vbCrLf ReDim Preserve arrHelp(i) arrHelp(i) = strHelp1 Next Set objMatches = Nothing Set objRE = Nothing strHTML = strHTML & "
" _ & strHelp1 & "" & strHelp2 _ & "
" & vbCrLf & vbCrLf ' Add the detailed text for each command For i = 0 To UBound( arrHelp ) strHTML = strHTML & GetCmdHelp( arrHelp(i) ) Next ' Write the "footer" strHTML = strHTML & "

 

" & vbCrLf & vbCrLf _ & "
" & vbCrLf _ & "

This HTML help file was generated by " _ & "AllHelp.vbs, Version " & strScriptVer _ & "
" & vbCrLf & "Written by Rob van der Woude
" _ & vbCrLf & "" _ & "http://www.robvanderwoude.com

" & vbCrLf _ & "
" & vbCrLf & vbCrLf & "" & vbCrLf & "" ' Write the complete HTML code to a file Set objHTMLFile = objFSO.CreateTextFile( strFile, blnOverwrite, False ) objHTMLFile.Write strHTML objHTMLFile.Close Set objHTMLFile = Nothing Set objFSO = Nothing 'Open the HTML file wshShell.Run """" & strFile & """", 0, False ' Close the last remaining object Set wshShell = Nothing If blnDebug Then Syntax Function GetCmdHelp( myCommand ) ' Get the help text for the specified command ' and format it to fit in the generated HTML page Set objExec = wshShell.Exec( "HELP " & myCommand ) strHelp2 = objExec.StdOut.ReadAll objExec.Terminate Set objExec = Nothing ' The following code checks if there is any help available ' at all; if not, it will try /? instead. ' This code is, unfortunately, language specific; add other ' languages if necessary. If InStrRev( strHelp2, "Try ""x /?"".", -1, 1 ) > 0 Then Set objExec = wshShell.Exec( myCommand & " /? 2>&1" ) strHelp2 = objExec.StdOut.ReadAll objExec.Terminate Set objExec = Nothing End If strHelp2 = Replace( strHelp2, "&", "&" ) strHelp2 = Replace( strHelp2, "^", "ˆ" ) strHelp2 = Replace( strHelp2, "<", "<" ) strHelp2 = Replace( strHelp2, ">", ">" ) GetCmdHelp = "

 

" & vbCrLf & vbCrLf & "

" & myCommand & "

" & vbCrLf & vbCrLf _ & "
" & vbCrLf & strHelp2 & "
" & vbCrLf & vbCrLf _ & "
Back to the top of " _ & "this page
" & vbCrLf & vbCrLf End Function Function GetOSLanguage( myLocale ) ' Get the description for the OS language/locale number Dim i, arrOSLanguage(20490) For i = 0 To 20490 arrOSLanguage(i) = "" Next arrOSLanguage(1) = "Arabic" arrOSLanguage(4) = "Chinese (Simplified) - China" arrOSLanguage(9) = "English" arrOSLanguage(1025) = "Arabic - Saudi Arabia" arrOSLanguage(1026) = "Bulgarian" arrOSLanguage(1027) = "Catalan" arrOSLanguage(1028) = "Chinese (Traditional) - Taiwan" arrOSLanguage(1029) = "Czech" arrOSLanguage(1030) = "Danish" arrOSLanguage(1031) = "German - Germany" arrOSLanguage(1032) = "Greek" arrOSLanguage(1033) = "English - United States" arrOSLanguage(1034) = "Spanish - Traditional Sort" arrOSLanguage(1035) = "Finnish" arrOSLanguage(1036) = "French - France" arrOSLanguage(1037) = "Hebrew" arrOSLanguage(1038) = "Hungarian" arrOSLanguage(1039) = "Icelandic" arrOSLanguage(1040) = "Italian - Italy" arrOSLanguage(1041) = "Japanese" arrOSLanguage(1042) = "Korean" arrOSLanguage(1043) = "Dutch - Netherlands" arrOSLanguage(1044) = "Norwegian - Bokmal" arrOSLanguage(1045) = "Polish" arrOSLanguage(1046) = "Portuguese - Brazil" arrOSLanguage(1047) = "Rhaeto-Romanic" arrOSLanguage(1048) = "Romanian" arrOSLanguage(1049) = "Russian" arrOSLanguage(1050) = "Croatian" arrOSLanguage(1051) = "Slovak" arrOSLanguage(1052) = "Albanian" arrOSLanguage(1053) = "Swedish" arrOSLanguage(1054) = "Thai" arrOSLanguage(1055) = "Turkish" arrOSLanguage(1056) = "Urdu" arrOSLanguage(1057) = "Indonesian" arrOSLanguage(1058) = "Ukrainian" arrOSLanguage(1059) = "Belarusian" arrOSLanguage(1060) = "Slovenian" arrOSLanguage(1061) = "Estonian" arrOSLanguage(1062) = "Latvian" arrOSLanguage(1063) = "Lithuanian" arrOSLanguage(1065) = "Persian" arrOSLanguage(1066) = "Vietnamese" arrOSLanguage(1069) = "Basque" arrOSLanguage(1070) = "Serbian" arrOSLanguage(1071) = "Macedonian (FYROM)" arrOSLanguage(1072) = "Sutu" arrOSLanguage(1073) = "Tsonga" arrOSLanguage(1074) = "Tswana" arrOSLanguage(1076) = "Xhosa" arrOSLanguage(1077) = "Zulu" arrOSLanguage(1078) = "Afrikaans" arrOSLanguage(1080) = "Faeroese" arrOSLanguage(1081) = "Hindi" arrOSLanguage(1082) = "Maltese" arrOSLanguage(1084) = "Gaelic" arrOSLanguage(1085) = "Yiddish" arrOSLanguage(1086) = "Malay - Malaysia" arrOSLanguage(2049) = "Arabic - Iraq" arrOSLanguage(2052) = "Chinese (Simplified) - PRC" arrOSLanguage(2055) = "German - Switzerland" arrOSLanguage(2057) = "English - United Kingdom" arrOSLanguage(2058) = "Spanish - Mexico" arrOSLanguage(2060) = "French - Belgium" arrOSLanguage(2064) = "Italian - Switzerland" arrOSLanguage(2067) = "Dutch - Belgium" arrOSLanguage(2068) = "Norwegian - Nynorsk" arrOSLanguage(2070) = "Portuguese - Portugal" arrOSLanguage(2072) = "Romanian - Moldova" arrOSLanguage(2073) = "Russian - Moldova" arrOSLanguage(2074) = "Serbian - Latin" arrOSLanguage(2077) = "Swedish - Finland" arrOSLanguage(3073) = "Arabic - Egypt" arrOSLanguage(3076) = "Chinese (Traditional) - Hong Kong SAR" arrOSLanguage(3079) = "German - Austria" arrOSLanguage(3081) = "English - Australia" arrOSLanguage(3082) = "Spanish - International Sort" arrOSLanguage(3084) = "French - Canada" arrOSLanguage(3098) = "Serbian - Cyrillic" arrOSLanguage(4097) = "Arabic - Libya" arrOSLanguage(4100) = "Chinese (Simplified) - Singapore" arrOSLanguage(4103) = "German - Luxembourg" arrOSLanguage(4105) = "English - Canada" arrOSLanguage(4106) = "Spanish - Guatemala" arrOSLanguage(4108) = "French - Switzerland" arrOSLanguage(5121) = "Arabic - Algeria" arrOSLanguage(5127) = "German - Liechtenstein" arrOSLanguage(5129) = "English - New Zealand" arrOSLanguage(5130) = "Spanish - Costa Rica" arrOSLanguage(5132) = "French - Luxembourg" arrOSLanguage(6145) = "Arabic - Morocco" arrOSLanguage(6153) = "English - Ireland" arrOSLanguage(6154) = "Spanish - Panama" arrOSLanguage(7169) = "Arabic - Tunisia" arrOSLanguage(7177) = "English - South Africa" arrOSLanguage(7178) = "Spanish - Dominican Republic" arrOSLanguage(8193) = "Arabic - Oman" arrOSLanguage(8201) = "English - Jamaica" arrOSLanguage(8202) = "Spanish - Venezuela" arrOSLanguage(9217) = "Arabic - Yemen" arrOSLanguage(9226) = "Spanish - Colombia" arrOSLanguage(10241) = "Arabic - Syria" arrOSLanguage(10249) = "English - Belize" arrOSLanguage(10250) = "Spanish - Peru" arrOSLanguage(11265) = "Arabic - Jordan" arrOSLanguage(11273) = "English - Trinidad" arrOSLanguage(11274) = "Spanish - Argentina" arrOSLanguage(12289) = "Arabic - Lebanon" arrOSLanguage(12298) = "Spanish - Ecuador" arrOSLanguage(13313) = "Arabic - Kuwait" arrOSLanguage(13322) = "Spanish - Chile" arrOSLanguage(14337) = "Arabic - U.A.E." arrOSLanguage(14346) = "Spanish - Uruguay" arrOSLanguage(15361) = "Arabic - Bahrain" arrOSLanguage(15370) = "Spanish - Paraguay" arrOSLanguage(16385) = "Arabic - Qatar" arrOSLanguage(16394) = "Spanish - Bolivia" arrOSLanguage(17418) = "Spanish - El Salvador" arrOSLanguage(18442) = "Spanish - Honduras" arrOSLanguage(19466) = "Spanish - Nicaragua" arrOSLanguage(20490) = "Spanish - Puerto Rico" If Trim( myLocale ) = "" Then GetOSLanguage = arrOSLanguage( GetLocale( ) ) Else GetOSLanguage = arrOSLanguage( myLocale ) End If End Function Sub Syntax ' Display help and, optionally, debugging information strMsg = strMsg & vbCrLf _ & "AllHelp.vbs, Version " & strScriptVer & vbCrLf _ & "Display help for ""all"" Windows commands, for" _ & vbCrLf _ & "the current Windows version and language." _ & vbCrLf & vbCrLf _ & "Usage: ALLHELP.VBS [ outputfile ] [ /Y ] [ /DEBUG ]" _ & vbCrLf & vbCrLf _ & "Where: ""outputfile"" is the fully qualified path of the HTML file to be" _ & vbCrLf _ & " created (default: ""allhelp.html"" in ""My Documents"")" _ & vbCrLf _ & " /DEBUG display debugging information" _ & vbCrLf _ & " /Y overwrite existing file (default: don't overwrite)" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit 1 End Sub