Transfer Network Printers Batch file

Have you ever wanted to use wmic to retrieve a list of printer just to find out it will not list networked printers.
wmic /node:”ComputerName” printer get name
Well I ran into this issue as well.

I wanted to create a script that looked at the printers on you old machine and added them to your new one.
All of the Network Printers are stored within the registry of the computer so if you are good enough you can find a way to retieve them.
You must be sure that you have remote registry service started.

set /p tempComputerName=Please enter the computer name=
if not %tempComputerName:~0,4%==172. (
    wmic /node:"%tempComputerName%" os get csname | findstr /i "%tempComputerName%"
    if errorlevel 1 (
    echo %errorlevel%
    goto failedLookup
for /f "tokens=* delims=" %%b in ('wmic useraccount where "name='%username%'" get sid ^| find "S-"') do set SID=%%b
for /f "tokens=3 delims=," %%c in ('reg query \\%tempComputerName%\HKU\%SID:~,-3%\Printers\Connections ^| find "print01"') do rundll32 printui.dll PrintUIEntry /in /n "\\print01\%%c"
:set default
for /f "tokens=3 delims= " %%d in ('reg query "\\%tempComputerName%\HKU\%SID:~,-3%\Software\Microsoft\Windows NT\CurrentVersion\Windows" /v Device ^| find "print01"') do set fullString=%%d
set endString=%fullString:*,=%
call set defaultPrinter=%%fullString:%endString%=%%
rundll32 printui.dll PrintUIEntry /y /n "%defaultPrinter:~,-1%"
goto end
echo The computer that you specificied is either off or has an old dns record.  If possible please specify the IP address.
goto end

I Commented out some descriptions so you know what was happening.
Feel free to modify and change as needed.
Have Fun.