Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer VBScript

Status
Not open for further replies.

eperrier

IS-IT--Management
Mar 13, 2004
22
US
I am looking for a simple VBScript that will map a group of printers and then check to see if that printer in that group is already mapped and if it is already mapped do not map that printer again. I have Thin Clients that my users log onto and then they RDS to my Terminal Servers. I also have some user that have a USB printer connected to the Thin Client, so i am trying not to bring over the mapped printers again in there session just the usb print.

Thank you
Edward Perrier


 
I thought this request sounded familiar

What is RDS? Those printers that are installed on the thin client will automatically be pulled over to a remote session

-Geates


"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
something like this

Code:
dim arrPrinters(4)

set objWMI     = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
set tblItems   = objWMI.ExecQuery("SELECT * FROM Win32_Printer")
set objNetwork = CreateObject("WScript.Network")

arrPrinters(0) = "\\server\printer01"
arrPrinters(1) = "\\server\printer02"
arrPrinters(2) = "\\server\printer06"
arrPrinters(3) = "\\server\printer10"
arrPrinters(4) = "\\server\printer13"

for each objItem in tblItems
	for i = 0 to ubound(arrPrinters)
		if (lcase(objItem.Name), lcase(arrPrinters(i))) then
			'printer already mapped
		else
			objNetwork.AddWindowsPrinterConnection arrPrinters(i)
		end if
	next
next

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hello

RDS is the new Remote Desktop Session For terminal server 2008.

Thank you for the reply that is what i am looking for.
 
oops

Code:
if (lcase(objItem.Name) [red]=[/red] lcase(arrPrinters(i))) then

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hello Geates,

Where does this line go in the code?


Thank you
Edward Perrier
 
in the for..loop

Code:
for each objItem in tblItems
    for i = 0 to ubound(arrPrinters)
[red]        if (lcase(objItem.Name) = lcase(arrPrinters(i))) then[/red]
            'printer already mapped
        else
            objNetwork.AddWindowsPrinterConnection arrPrinters(i)
        end if
    next
next

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top