Microsoft
Software
Hardware
Network
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.Netw
ork")
objNetwork.AddWindowsPrint
erConnecti
on "\\printserver\ColorPrinte
r"
objNetwork.AddWindowsPrint
erConnecti
on "\\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/t
echnet/sys
internals/
utilities/
psexec.msp
x
:: * 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\PR
INTER <- 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\PR
INTER
ECHO On Error Resume Next >MapPrn.vbs
ECHO Set objNetwork = CreateObject^("WScript.Net
work"^) >>MapPrn.vbs
ECHO objNetwork.AddWindowsPrint
erConnecti
on "%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
No network board driver has been selected on Novell Netware installation
cisco access-list
When using smarthost for outgoing SMTP, how are error messages routed?
Retrieve Email from Yahoo Mail into Outlook
Cannot send outgoing mail in Outlook 2003, XP
What is the best way to introduce VoIP into our network?
Network Printer config Question
DHCP Lease with no Computer Name
Setup of Windows 2003 server
GROUP POLICY FOLDERS ON SYSVOL MISSING