Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Search Registry ValueName and its Value for a lot of subkeys

$
0
0

Hi guys,

I have one vb script for local printers:

Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Dim oReg : Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Dim oShell : Set oShell = CreateObject("WScript.Shell")
Dim sPath, aSub, sKey, aSubToo, sKeyToo, StringValue, StringValue1

' Get all keys within sPath
sPath = "SYSTEM\CurrentControlSet\Control\Print\Printers"
oReg.EnumKey HKEY_LOCAL_MACHINE, sPath, aSub

' Loop through each key
For Each sKey In aSub
    ' Get all subkeys within the key 'sKey'
	oReg.GetStringValue HKEY_LOCAL_MACHINE, sPath & "\" & sKey , "Printer Driver", StringValue

	If StringValue = "MyOwnPrinterDriverName" Then
    Wscript.Echo "Test of " & sPath & "\" & sKey & "\" & sKeyToo & " = " & StringValue
	Wscript.Echo StringValue

	End IF

Next

For local printers there will be one reg value name "Printer Driver" and the value is my goal. This will work for local printers, but not for network printers, because network printer are located in another regkey "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\Client Side Rendering Print Provider\Servers\"PrinterName"\Printers\"ID"

The problem is, "Printer Name" and "ID" is unknown, so I need one script update, which will search all subkeys after "ID".

The main goal is to search for the printer name, and all what I have is his driver name :)

Thx for u help :)


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>