(view source code of devcon_help.vbs as plain text)
Option ExplicitDim arrCommands, arrLines, arrPATHDim blnFirstLinkDim i, intPosDim objExec, objFSO, objHTMLFile, objRE, wshShellDim strCommand, strDEVCON, strHTMLCode, strHTMLFile, strLine, strMsg, strOutput, strPATH, strScriptFile, strScriptVer, strVersionstrScriptVer = "1.00"
strMsg = ""
If WScript.Arguments.Named.Count > 0 Then Syntax
If WScript.Arguments.Unnamed.Count > 1 Then Syntax
Set wshShell = CreateObject( "WScript.Shell" )
Set objExec = wshShell.Exec( "DEVCON.EXE Help" )
If objExec.ExitCode <> 0 Then
strMsg = "ERROR: DEVCON not found, not in the current directory, nor in the PATH\n\n"
Syntax
End If
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
With objFSOIf WScript.Arguments.Unnamed.Count = 1 Then
If .FolderExists( .GetParentFolderName( WScript.Arguments.Unnamed(0) ) ) Then
strHTMLFile = .GetAbsolutePathName( WScript.Arguments.Unnamed(0) )
ElsestrMsg = "ERROR: invalid path for HTML output file\n\n"
Syntax
End If
ElsestrScriptFile = WScript.ScriptFullName
strHTMLFile = .BuildPath( .GetParentFolderName( strScriptFile ), .GetBaseName( strScriptFile ) & ".html" )
End If
End With
strDEVCON = ""
strVersion = ""
strPATH = wshShell.ExpandEnvironmentStrings( wshShell.CurrentDirectory & ";%PATH%" )
arrPATH = Split( strPATH, ";" )
For i = 0 To UBound( arrPATH )
If Trim( arrPATH(i) ) <> "" Then
If strDEVCON = "" Then
With objFSOIf .FileExists( .BuildPath( arrPATH(i), "DEVCON.EXE" ) ) Then
strDEVCON = .BuildPath( arrPATH(i), "DEVCON.EXE" )
strVersion = .GetFileVersion( strDEVCON )
End If
End With
End If
End If
NextSet arrCommands = CreateObject( "System.Collections.ArrayList" )
strHTMLCode = "<!DOCTYPE HTML>\n<html>\n<head>\n<title>Help for DEVCON " & strVersion & "</title>\n</head>\n"
strHTMLCode = strHTMLCode & "<body>\n\n<div style=""max-width: 800px; text-align: center; margin-left: auto; margin-right: auto;"">\n\n<div style=""max-width: 800px; text-align: left;"">\n\n<h1>help for <a href=""http://www.robvanderwoude.com/devcon.php"">DEVCON</a> " & strVersion & "</h1>\n\n<pre>"
strOutput = objExec.StdOut.ReadAll
arrLines = Split( strOutput, vbCrLf )
blnFirstLink = False
For i = 0 To UBound( arrLines )
strLine = Escape( arrLines(i) )
If InStr( arrLines(i), Space( 9 ) ) > 2 And Left( arrLines(i), 4 ) <> "help" And Left( arrLines(i), 1 ) <> "-" Then
intPos = InStr( strLine, " " )
strCommand = Left( strLine, intPos - 1 )
arrCommands.Add strCommand
strLine = "<a href=""#helptext_" & strCommand & """>" & strCommand & "</a>" & Escape( Mid( strLine, intPos ) )
If Not blnFirstLink Then
strLine = "\n" & strLine
blnFirstLink = True
End If
End If
strHTMLCode = strHTMLCode & "\n" & strLine
NextarrCommands.Sort
strHTMLCode = SuperTrim( strHTMLCode ) & "</pre>\n\n"
strHTMLCode = strHTMLCode & "<p>Type <code>DEVCON help <em>command</em></code> on the command line for detailed help on <em>command</em>.</p>\n\n"
For Each strCommand In arrCommands
Set objExec = wshShell.Exec( "DEVCON.EXE Help " & strCommand )
If objExec.ExitCode = 0 Then
strHTMLCode = strHTMLCode & "<h2 id=""helptext_" & strCommand & """>DEVCON " & strCommand & "</h2>\n\n<pre>"
strHTMLCode = strHTMLCode & SuperTrim( Escape( objExec.StdOut.ReadAll ) )
strHTMLCode = strHTMLCode & "</pre>\n\n<p style=""text-align: center;""><a href=""" & objFSO.GetFileName( strHTMLFile ) & """>Back to the top of the page</a></p>\n\n<p> </p>\n\n"
End If
NextstrHTMLCode = Replace( strHTMLCode & "</div>\n\n<p> </p>\n\n<p style=""text-align: center;"">HTML page generated by devcon_help.vbs, Version " & strScriptVer & "<br />\nWritten by Rob van der Woude<br />\n<a href=""http://www.robvanderwoude.com"">http://www.robvanderwoude.com</a></p>\n\n</div>\n\n</body>\n</html>", "\n", vbCrLf )
Set objHTMLFile = objFSO.CreateTextFile( strHTMLFile, True, True )
objHTMLFile.Write( strHTMLCode )
objHTMLFile.Close
wshShell.Run strHTMLFile, 1, False
Abort 0Sub Abort( intRC )
On Error Resume Next
Set wshShell = Nothing
Set objExec = Nothing
Set objFSO = Nothing
Set objRE = Nothing
Set objHTMLFile = Nothing
On Error Goto 0
WScript.Quit intRC
End Sub
Function Escape( strInput )
Dim strResultstrResult = Replace( strInput, "&", "&" )
strResult = Replace( strResult, ">", ">" )
strResult = Replace( strResult, "<", "<" )
Escape = strResultEnd Function
Function SuperTrim( strInput )
Dim strResult strResult = strInputSet objRE = New RegExp
objRE.Pattern = "\s+$"
If objRE.Test( strResult ) Then strResult = objRE.Replace( strResult, "" )
objRE.Pattern = "^[\n\r]+"
If objRE.Test( strResult ) Then strResult = objRE.Replace( strResult, "" )
SuperTrim = strResultEnd Function
Sub Syntax( )
strMsg = strMsg _& "devcon_help.vbs, Version " & strScriptVer _
& "\nCreate an HTML help page for all commands for the current DEVCON version\n\n" _
& "Usage: devcon_help.vbs [ outputfile ]\n\n" _
& "Where: outputfile is the HTML file to be created (default: name\n" _
& " and location of this script, extension "".html"")\n\n" _
& "Note: DEVCON is a free Microsoft utility, part of the Windows Driver Kit:\n" _
& " https://www.microsoft.com/en-us/download/details.aspx?id=11800\n" _
& " See http://www.robvanderwoude.com/devcon.php for help on\n" _
& " getting it installed without the entire Windows Driver Kit.\n\n" _
& "Written by Rob van der Woude\nhttp://www.robvanderwoude.com"
WScript.Echo Replace( strMsg, "\n", vbCrLf )
Abort 1End Sub
page last modified: 2025-10-11; loaded in 0.0124 seconds