In tip 2014 » Windows 2000 can add local and remote printers from the command line, I described the rundll32 printui.dll,PrintUIEntry command.

When you type rundll32 printui.dll,PrintUIEntry /?, you see:

The /ga switch adds the printer to all users who log onto the target computer.

I have scripted NetworkPrinter.bat to add a network printer to all users who log on to the target computer.

The syntax for using NetworkPrinter.bat is:

NetworkPrinter \\Workstation \\Server\PrinterShare

Where \\Workstation is the remote (or local) target computer, and \\Server\PrinterShare is the network printer.

NOTE: NetworkPrinter.bat uses sc.exe and reg.exe, built into Windows XP, Windows Server 2003, and later, or installed on Windows 2000 from the Resource Kit and the Support Tools on the Windows 2000 CD-ROM.

NetworkPrinter.bat contains:

                              @echo off                              if \{%2\}==\{\} @echo Syntax: NetworkPrinter \\Workstation \\Server\PrinterShare&goto :EOF                               setlocal ENABLEDELAYEDEXPANSION                              set ws=%1                              set prt=%2                              set work="%TEMP%\Network_Printer_%RANDOM%.TMP"                              if exist %work% del /q %work%                              :: Locate any services that depend on the Spooler service.                              set key=HKLM\SYSTEM\CurrentControlSet\Services                              for /f "Tokens=*" %%a in ('reg query %ws%\%key%^|FIND "HKEY_LOCAL_MACHINE"') Do (                               set svc=%%a                               set svc=%ws%\!svc:*\SYSTEM=HKLM\SYSTEM!                               call :quiet2 "!svc!">nul 2>&1                              )                              call :quiet1>nul 2>&1                              if exist %work% del /q %work%                              endlocal                              goto :EOF                              :quiet1                              rundll32 printui.dll,PrintUIEntry /ga /c%ws% /n%prt%                              if not exist %work% goto ss1                              :: Stop dependent services                              for /f "Tokens=*" %%a in ('type %work%') do (                               sc %ws% stop "%%a"                              )                              :: Wait 6 seconds                              @ping -n 7>nul                              :ss1                              sc %ws% stop spooler                              @ping -n 7>nul                              sc %ws% start spooler                              if not exist %work% goto :EOF                              @ping -n 7>nul                              :: Start dependent services                              for /f "Tokens=*" %%a in ('type %work%') do (                               sc %ws% start "%%a"                              )                              goto :EOF                              :quiet2                              set OK=N                              for /f "Tokens=*" %%b in ('reg query %1^|Findstr /i /c:"DependOnService"^|find /i "Spooler\"') do (                               set OK=Y                              )                              if "%OK%" EQU "N" goto :EOF                              set dos=%1                              set dos=%dos:"=%                              call set dos=%%dos:%ws%=%%                              set dos=%dos:\HKLM\SYSTEM\CurrentControlSet\Services\=%                              @echo %dos%>>%work%