I have the following code which goes through several registry keys and outputs all vales and their corresponding data to a text file. The keys relate to known printer settings location which enumerates stuff like printer IP, printer port, printer name etc. So the script must go through all of them.
Code: Select all
pushd %~dp0
ver | find "6.1" > nul
if %errorlevel%==0 goto win7
:win8
reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\SWD\DAFWSDProvider /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Print /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print /s >>_%computername%_printers.txt
goto exit
:win7
reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Print /s >>_%computername%_printers.txt
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print /s >>_%computername%_printers.txt
:exit
exit
The link below is a snippet of the output. The original output contains from 2.000 to 5.000 lines.
http://pastebin.com/gMSudq66
What I would like is to extract is the IP address and the name (if possible) from the output file and append them to the top of the output file, keeping the data already in it. Due to the fact that each manufacturer stores the IP and name differently, some may use the FriendlyName value others just use the Name value. Some might have the name and IP in different keys.
The IP addresses range from Class C to Class B and even Class A.
Thank you for your time and patience.