(view source code of getprint.vbs as plain text)
Option ExplicitDim arrAssoc, arrKeys, arrSubKeysDim i, jDim objDic, objRegDim strFileType, strLine, strKey, strSubKey, strSubSubKey, strValueConst HKCR = &H80000000
' No command line arguments requiredIf WScript.Arguments.Count > 0 Then Syntax
Set objReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!//./root/default:StdRegProv" )
Set objDic = CreateObject( "Scripting.Dictionary" )
' List all keys in the HKEY_CLASSES_ROOT hiveobjReg.EnumKey HKCR, "", arrKeys
For i = 0 To UBound( arrKeys )
' Store registered extensions and their associated file types in a dictionaryIf Left( arrKeys(i), 1 ) = "." Then
objReg.GetStringValue HKCR, arrKeys(i), "", strFileType
objDic.Item( strFileType) = arrKeys(i)
End If
' Check if any commands are available for a file typestrSubKey = arrKeys(i) & "\shell"
objReg.EnumKey HKCR, strSubKey, arrSubKeys
If IsArray( arrSubKeys ) Then
strLine = ""
For j = 0 To UBound( arrSubKeys )
If Left( LCase( arrSubKeys(j) ), 5 ) = "print" Then
' Skip DDE print commandsstrSubSubKey = arrKeys(i) & "\shell\" & arrSubKeys(j) & "\ddeexec"
objReg.GetStringValue HKCR, strSubSubKey, "", strValue
If Trim( strValue ) <> "" Then Exit For
' Display the print commandstrSubSubKey = arrKeys(i) & "\shell\" & arrSubKeys(j) & "\command"
objReg.GetStringValue HKCR, strSubSubKey, "", strValue
strFileType = Split( strSubSubKey, "\" )(0)
WScript.Echo objDic.Item( strFileType ) & vbTab _
& strFileType & vbTab _
& arrSubKeys(j) & vbTab & strValue
End If
NextEnd If
arrSubKeys = ""
NextSet objDic = Nothing
Set objReg = Nothing
Sub SyntaxWScript.Echo vbCrLf _
& "GetPrint.vbs, Version 2.01" _
& vbCrLf _& "List Print and PrintTo commands for all registered file types" _
& vbCrLf & vbCrLf _
& "Usage: CSCRIPT.EXE //NoLogo GETPRINT.VBS" _
& vbCrLf & vbCrLf _
& "Notes: Only one file extension will be listed for each registered file type." _
& vbCrLf _& " This script will list (non-DDE) print commands for all registered file" _
& vbCrLf _& " types. To find print commands for a specific file type, use ASSOC and" _
& vbCrLf _& " FINDSTR. E.g. to find the print commands for font files (*.fon):" _
& vbCrLf & vbCrLf _
& " ASSOC .fon" _
& vbCrLf & vbCrLf _
& " .fon=fonfile" _
& vbCrLf & vbCrLf _
& " CSCRIPT GETPRINT.VBS | FINDSTR /R /I /B /C:""fonfile""" _
& vbCrLf & vbCrLf _
& " .fon fonfile print C:\WINDOWS\System32\fontview.exe /p %1" _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" _
& vbCrLf _& "http://www.robvanderwoude.com"
WScript.Quit 1
End Sub
page last modified: 2025-10-11; loaded in 0.0112 seconds