List installed/mapped newtork printers in a PC for a user remotely

ryder0707
ryder0707 used Ask the Experts™
on
How do i list all the installed/mapped newtork printers in a specific PC for a domain user remotely? Assuming the user had logon to the PC before
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
it is stored in the users' profile. Open regedit and load hive NTUSER.DAT from user's profile directory. Then navigate to "Printers\Connections" where you can find the list of printer names including the print server name.
Top Expert 2009

Author

Commented:
Can i do it remotely? Is it possible to load hive while user is logon? Any impact to the user?

Commented:
The user won't notice anything. If it's just to look there.
no, you cannot load or copy this file while the user is loggen on. However if you use roaming profiles, you can copy it from the server. If the user is logged on you can also get the printer information from the loaded user hive. Open regedit, connect to the remote PC and go to HKEY_USERS and select the right user account. It should be easy if you have the user's SID. If not, there should be only one key with a long SID name.

Commented:
In the following page you will find some nice vbs scripts from Microsoft that work for local and remote computers. Just use them...

http://technet.microsoft.com/en-us/library/cc782930%28WS.10%29.aspx
hi .. u can connect remotely to his registry via remote registry and check the following locations in his registry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\LanMan Print Services\Servers\"your server"\Printers\your printer

HKEY_USERS\"SSID of user""S-1-5-21"""\Printers\Connections\,,your printer

HKEY_USERS\"SSID of user""\Printers\Settings

HKEY_USERS\"SSID of user"\Software\Microsoft\Windows NT\CurrentVersion\Devices

HKEY_USERS\SSID of user"\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts

The remote registry service must be enabled on his system
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer
Commented:
I am posting this here as well as I believe this script solves your issue in both articles.  My script will connect to a remote computer, mount the hive of a user you specified, and output a list of all the printers in that user's registry.

NOTES:

* If the User is logged on this will not work, you will need to connect to the registry remotely instead, which can be accomplished with a minor change to my script.

* If a printer has been uninstalled from that user the printer will not appear on the list because it will not exist in the registry..

::------------------------------------------------------------------------------------------------::
:: Script: FindRemotePrinter.Bat                                            				 	  ::
:: Version: 1.0                                                                                   ::
:: Copyright: Ben Personick                                                                       ::
:: Date: 2010-07-06                                                                               ::
::                                                                                                ::
::                                                                                                ::
:: Desc: This script Mounts a Registry Hive on a machine and parses the names of the printers	  ::
::																								  ::
::------------------------------------------------------------------------------------------------::
:Begin
@ECHO OFF

::------------------------------------------------------------------------------------------------::
:: This section sets up default variable settings and sets the logging directory and file name.   ::
::------------------------------------------------------------------------------------------------::
:Start-Prep
	CALL :Start-Set-Date
	GOTO :End-Set-Date
	:Start-Set-Date
		SET TDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
		SET TTime=%Time:~0,2%.%Time:~3,2%.%Time:~6,2%
		GOTO :EOF
	:End-Set-Date
	SET Preamble=FindRemotePrinter --
	SET SrcUser=USERNAME_To_Find_Printers_Of
	SET SrcComputer=REMOTE_COMPUTERNAME_NO_\\s
	SET SrcShare=C$\Documents And Settings
	SET PLog=%SrcComputer%_%SrcUser%_%TDATE%_%TTIME%.log
	SET IDir=c:\FindRemotePrinter\Log
	SET ILog=ILog_%TDate%_%TTime%.Log
	:Start-IDir
		ECHO %Preamble% Checking For %IDir%
		IF EXIST %IDir% ECHO %Preamble% IDir "%IDir%" -- Found! -- GOTO End-Prep >> %IDir%\%ILog%
		IF EXIST %IDir% GOTO End-IDir
		ECHO %Preamble% Creating %IDir%
		mkdir %IDir%
	:End-IDir

:End-Prep

:Start-Main-Processing

	:Start-PrintLog-Header
	ECHO --------------------------------------------- >> %IDir%\%PLog%
	ECHO -- Computer: %SrcComputer%					-- >> %IDir%\%PLog%
	ECHO -- User: %SrcUser%							-- >> %IDir%\%PLog%
	ECHO -- Date: %TDate%							-- >> %IDir%\%PLog%
	ECHO -- Time: %TTime%							-- >> %IDir%\%PLog%
	ECHO --------------------------------------------- >> %IDir%\%PLog%
	ECHO. >> %IDir%\%PLog%
	ECHO --------------------------------------------- >> %IDir%\%PLog%
	ECHO -- The Following Printers Were Discovered:	-- >> %IDir%\%PLog%
	ECHO --------------------------------------------- >> %IDir%\%PLog%
	:End-Printlog-Header


	:Start-Open-Reg-File
		reg LOAD HKEY_USERS\%SrcUser% "\\%SrcComputer%\%SrcShare%\%SrcUser%\NTUSER.DAT"
	:End-Open-Reg-File

	:Start-Find-Printer
		ECHO %Preamble% Start-Find-Printer --
		ECHO %Preamble% Start-Find-Printer -- >> %IDir%\%ILog%
		for /F %%A IN ('reg query HKEY_USERS\%SrcUser%\Printers\ /s') DO CALL :Start-Print-Loop %%A
		GOTO End-Find-Printer
		:Start-Print-Loop
			SET PTemp=%1
			ECHO %PTemp% | FIND /I "HKEY_USERS"
			IF ERRORLEVEL 1 GOTO Start-IS-Printer
			GOTO END-IS-Printer
			:Start-Check-Default
				ECHO %PTemp% | FIND /I "Default"
				IF ERRORLEVEL 1 GOTO Start-IS-Printer
				GOTO END-IS-Printer
			:End-Check-Default

			:Start-IS-Printer
				ECHO %Preamble% The following Printer was Found - %PTemp% -- And Stored in %IDir%\%PLog% --
				ECHO %PTemp% >> %IDir%\%PLog%
				ECHO %Preamble% The following Printer was Found - %PTemp% -- And Stored in %IDir%\%PLog% -- >> %IDir%\%ILog%
			:END-IS-Printer
			GOTO :EOF
		:End-Print-Loop	
	
	:End-Find-Printer
	ECHO %Preamble% The Registry has no more entries at %LookupKey% --
	ECHO %Preamble% The Registry has no more entries at %LookupKey% -- >> %IDir%\%ILog%	

	:Start-Close-Reg-File
		reg UNLOAD HKEY_USERS\%SrcUser%
	:End-Close-Reg-File
	
:End-Main-Processing


:End
	CALL :Start-Set-Date
	ECHO %Preamble% The Batch File Completed ON %TDATE% AT %TTIME% --
	ECHO %Preamble% The Batch File Completed ON %TDATE% AT %TTIME% -- >> %IDir%\%ILog%

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial