NursingCorp
asked on
Script to Connect Network Printers on non-domain computers.
Hey everybody!
Here's the situation. I have a couple of multipurpose printer/fax/scanners on the network. Everyone that brings in their laptop needs to be able to use those printers, but nobody has domain accounts to log in and share the printer from the server.
Up to now, we us a script to map a drive to the server, run a vb script to install the printers and then disconnect the drive. However, now there are users who have vista and windows 7 x64, and the printer intall does not work.
Attached is the install script. Can someone help me modify this to work with Vista and Windows 7 x64? This is just for one printer, I have another script for the other printer. I would like to have them both installed with one script, but can't figure that part out either.
Thanks in advance for the help!
Here's the situation. I have a couple of multipurpose printer/fax/scanners on the network. Everyone that brings in their laptop needs to be able to use those printers, but nobody has domain accounts to log in and share the printer from the server.
Up to now, we us a script to map a drive to the server, run a vb script to install the printers and then disconnect the drive. However, now there are users who have vista and windows 7 x64, and the printer intall does not work.
Attached is the install script. Can someone help me modify this to work with Vista and Windows 7 x64? This is just for one printer, I have another script for the other printer. I would like to have them both installed with one script, but can't figure that part out either.
Thanks in advance for the help!
Dim oShell
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "regsvr32 /s \\server\shared\Departments\IT\drivers\PrinterDLL\prnadmin.dll", 1, true
Set oShell = Nothing
Dim oPrinter
Dim oMaster
Set WshNetwork = WScript.CreateObject("WScript.Network")
'gets computer name
strComputer = WshNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
'before adding printer we need to create ports that printers will use
objNewPort.Name = "IP_192.168.111.85:print"
objNewPort.Protocol = 2
objNewPort.HostAddress = "192.168.111.85"
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_
set oPrinter = CreateObject("Printer.Printer.1")
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
oPrinter.PrinterName = "RICOH Aficio MP C6000 PCL 5c" ' name of printer how it's appear at printer' s directory
oPrinter.DriverPath = "\\server\Shared\Departments\IT\Drivers\Ricoh_6000" 'if there is special driver to install you must indicate a path
oPrinter.InfFile = "\\server\Shared\Departments\IT\Drivers\Ricoh_6000\OEMSETUP.inf"
oPrinter.DriverName = "RICOH Aficio MP C6000 PCL 5c" ' name of printer whow it's apear in ntprint.inf
oPrinter.PortName = "IP_192.168.111.85:print" ' name of port that you created before
oMaster.PrinterAdd oPrinter
If Err <> 0 then
msgbox "Error on installation of printers."
end if
msgbox "Your printer is now installed and ready to use."
ASKER
Thank you for the reply. This works fine on the 32bit systems, and when I get to a 64bit, it says that activex could not create the object "Printer.Printer.1".
ASKER
The drivers are valid and exist, I just put them there from the Ricoh website.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I left the part in there to check 64 vs. 32 bit... not sure if the drivers work on both or not. Ricoh had separate ones for 64 & 32 on the website.
Thanks,
Joe
Thanks,
Joe
ASKER
Right On!!! You rock, that did the trick perfectly!
Thank you so much!
Thank you so much!
ASKER
Best response ever, thanks!
woohoo! Glad I could help... and learned some stuff in the process.
Thanks,
Joe
Thanks,
Joe
ASKER
Yeah, they have different divers based on the os, that was the problem, so this is checking to see what version, and then selecting the right version for install, I love it!
You could have the script determine whether it's 64/32 bit and select which folder.
This script assumes a new folder for 64bit drivers. I have not tested it...
Open in new window