(view source code of getprint.vbs as plain text)
Option Explicit
Dim arrAssoc, arrKeys, arrSubKeys
Dim i, j
Dim objDic, objReg
Dim strFileType, strLine, strKey, strSubKey, strSubSubKey, strValue
Const HKCR = &H80000000
' No command line arguments required
If 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 hive
objReg.EnumKey HKCR, "", arrKeys
For i = 0 To UBound( arrKeys )
' Store registered extensions and their associated file types in a dictionary
If 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 type
strSubKey = 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 commands
strSubSubKey = arrKeys(i) & "\shell\" & arrSubKeys(j) & "\ddeexec"
objReg.GetStringValue HKCR, strSubSubKey, "", strValue
If Trim( strValue ) <> "" Then Exit For
' Display the print command
strSubSubKey = 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
Next
End If
arrSubKeys = ""
Next
Set objDic = Nothing
Set objReg = Nothing
Sub Syntax
WScript.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: 2024-04-16; loaded in 0.0086 seconds