r3helpdesk
asked on
manage network printers via logon vbscript
Hello again
I'm trying to create a logon script which should add a few network shared printers from a windows server but beside this I first need to remove all network printers belonging to the actual domain where the workstation is connected and keep existing local printers and network printers from other domains.
For example, we have a domain A with network printers Pa1 and Pa2 and a domain B with with network printers Pb1 and Pb2. Running the script on a notebook named Na1 (which is connected on the domain A) should remove all the printers from domain A (Pa1,Pa2) but not from domain B (Pb1,Pb2) or any other local printers and then should add back Pa1 and Pa2.
Thank you guys!
I'm trying to create a logon script which should add a few network shared printers from a windows server but beside this I first need to remove all network printers belonging to the actual domain where the workstation is connected and keep existing local printers and network printers from other domains.
For example, we have a domain A with network printers Pa1 and Pa2 and a domain B with with network printers Pb1 and Pb2. Running the script on a notebook named Na1 (which is connected on the domain A) should remove all the printers from domain A (Pa1,Pa2) but not from domain B (Pb1,Pb2) or any other local printers and then should add back Pa1 and Pa2.
Thank you guys!
well for the adding the printer bit I think this should do it;
' Example VBScript to map a printer on a server
' Guy Thomas February 2004.
' ************************** ****
Option Explicit
Dim netPrinter, UNCpath
UNCpath = "\\YourServer\PrinterName"
Set netPrinter = CreateObject("WScript.Netw ork")
netPrinter.AddWindowsPrint erConnecti on UNCpath
WScript.Echo "Your printer is mapped from : " & UNCpath
WScript.Quit
' End of example VBScript
' Example VBScript to remove a Printer
' Guy Thomas February 2004.
' ************************** ****
Option Explicit
Dim DelPrint, UNCpath
UNCpath = "\\YourServer\PrinterName"
Set DelPrint = WScript.CreateObject("WScr ipt.Networ k")
DelPrint.RemovePrinterConn ection UNCpath, true, true
Wscript.Echo "This printer was removed : " & UNCpath
WScript.Quit
' End of Example Script to remove printer
This is taken from http://www.computerperformance.co.uk/ezine/ezine16.htm
for further reading in regards to adding/removing also check out http://www.computerperformance.co.uk/Logon/Logon_Remove_Printer.htm
' Example VBScript to map a printer on a server
' Guy Thomas February 2004.
' **************************
Option Explicit
Dim netPrinter, UNCpath
UNCpath = "\\YourServer\PrinterName"
Set netPrinter = CreateObject("WScript.Netw
netPrinter.AddWindowsPrint
WScript.Echo "Your printer is mapped from : " & UNCpath
WScript.Quit
' End of example VBScript
' Example VBScript to remove a Printer
' Guy Thomas February 2004.
' **************************
Option Explicit
Dim DelPrint, UNCpath
UNCpath = "\\YourServer\PrinterName"
Set DelPrint = WScript.CreateObject("WScr
DelPrint.RemovePrinterConn
Wscript.Echo "This printer was removed : " & UNCpath
WScript.Quit
' End of Example Script to remove printer
This is taken from http://www.computerperformance.co.uk/ezine/ezine16.htm
for further reading in regards to adding/removing also check out http://www.computerperformance.co.uk/Logon/Logon_Remove_Printer.htm
and what yehudaha is saying is correct.
Though you could maybe use an IF command to check the UNC path for information matching domain information.
These are just thoughts though, I'm a beginner with VBScript.
Though you could maybe use an IF command to check the UNC path for information matching domain information.
These are just thoughts though, I'm a beginner with VBScript.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
An answer to the problem is no more needed
The activity was abandoned
The activity was abandoned
i don't think in a script or any other method can identify from with domain a printer was
connected to a computer.