Question : Install and Remote network printers

I need to remove and add network printers from multiple computers. In the past i have used a simple script like this:
On Error Resume Next


Set objNetwork = CreateObject("WScript.Network")
 objNetwork.AddWindowsPrinterConnection "\\printserver\ColorPrinter"
 objNetwork.AddWindowsPrinterConnection "\\printserver\MainPrinter"


This worked fine for a login script. But now i need to run this against a set of multiple comptuers on our network. I would like to run it by subnet if possible.

Answer : Install and Remote network printers

Greetings DJohnson104, Sorry for the delay.  
Check following script. You need to add computer names inside the file (you can use IP Scanner to get particular subnet computer names).
Read the instructions and run the script from command prompt.

Hope this helps.

:: ================
:: READ THIS FIRST
:: ================
:: * You need to have Administrative rights to run this script
:: * This script require "Computers.txt" file from where it will pick computer names.
:: * This script requires "PSExec.exe" (comes with PSTools) to execute bat file on remote system.
::     - Download it from Microsoft site
::       http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx
:: * You need to set AdimUsername, AdminPassword and NetworkPrinter variables inside the script
::    - Like:
::              SET AdimUsername=FKazi                         <- username having Administrative rights
::              SET AdminPassword=MyPassword             <- user password
::              SET NetworkPrinter=\\SERVER\PRINTER       <- Network Printer Path
:: * Copy and Paste following script into notepad and save it with any name having .cmd extension.
:: All three files (ScriptFile.cmd, Computers.txt, and PSExec.exe) should on the same path
:: SCRIPT START

@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET AdimUsername=Administrator
SET AdminPassword=MyPassword
SET NetworkPrinter=\\SERVER\PRINTER

ECHO On Error Resume Next >MapPrn.vbs
ECHO Set objNetwork = CreateObject^("WScript.Network"^) >>MapPrn.vbs
ECHO objNetwork.AddWindowsPrinterConnection "%NetworkPrinter%" >>MapPrn.vbs

IF NOT EXIST Computers.txt Goto ShowErr
FOR %%R IN (Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
FOR /F %%c IN ('Type Computers.txt') Do (
    IF /I NOT "%%c"=="!COMPUTERNAME!" (
            Echo Processing: %%c
            PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL
            IF NOT ErrorLevel 1 (
                  Copy /Y MapPrn.vbs \\%%c\C$ >NUL
                  PSExec -i -u !AdimUsername! -p !AdminPassword! \\%%c WScript.exe C:\MapPrn.vbs
                  DEL /F /Q \\%%c\C$\MapPrn.vbs
            )ELSE (Echo %%c: Not able to connect)
      )ELSE (ECHO Skipping: %%c)
)
Goto EndScript
:ShowErr
Echo "Computers.txt" file does not exist or file is empty!
:EndScript
IF EXIST MapPrn.vbs DEL /F /Q MapPrn.vbs
ENDLOCAL
EXIT /B 0
:: SCRIPT END
Random Solutions  
 
programming4us programming4us