Printer Script doesn't work - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Hardware > Monitors, Printers and Peripherals
Click Here to Login
Reply
 
Thread Tools Display Modes
 
Old 02-11-2014, 04:16 AM   #1 (permalink)
Newb Techie
 
Join Date: Feb 2014
Location: Netherlands
Posts: 2
Default Printer Script doesn't work

I want to add a printer with VBScript.

The one I'm using is.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

strIPAddress = "192.168.226.6"
strDriverName = "HP Universal Printing PCL 6"
strQueueName = "HP OfficeJet Pro 8600"
strLocation = "Helpdesk"

'--- in case the driver is already there
REM *** Installs printer driver needed for Universal PLC6 64 Bit
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP Universal Printing PCL 6"
objDriver.SupportedPlatform = "Windows NT x64"
objDriver.Version = "3"
objDriver.DriverPath = "C:\___Niet werkende drivers\HP Universal Print Driver\pcl6-x64-5.7.0.16448\"
objDriver.Infname = "C:\___Niet werkende drivers\HP Universal Print Driver\pcl6-x64-5.7.0.16448\hpcu155u.inf"
intResult = objDriver.AddPrinterDriver(objDriver)

rem *** Installs a TCP/IP printer local port on a computer
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_" & strIPAddress
objNewPort.Protocol = 1
objNewPort.HostAddress = "."
objNewPort.SNMPEnabled = False
objNewPort.Put_

rem *** installs printer
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = strDriverName
objPrinter.PortName = "IP_" & strIPAddress
objPrinter.DeviceID = strQueueName
objPrinter.Location = strLocation
objPrinter.Put_


As you can see I'm using a "HP Universal Printing PCL 6" driver.

Can anybody please help me

Thanks in advance.

Poseidon
__________________

poseidon is offline   Reply With Quote
Old 02-11-2014, 09:37 AM   #2 (permalink)
Private Joker
 
carnageX's Avatar
 
Join Date: Feb 2007
Location: South Dakota
Posts: 24,515
Default Re: Printer Script doesn't work

So what part of it doesn't work? Have you tried stepping through each line of your code to see if it's working like it should?
__________________

__________________
Laptop: MSI GT70 2OC-059us | i7-4700MQ | 16GB | GTX 770m | 500GB SSD / 750GB HDD | 17.3" | Win10 Pro
Desktop: 4690k | 12GB g.Skill RipJaws | GTX 970 | 520hx | Z87X-UD4H | Corsair Vengeance C70 | Corsair H110 | Acer 25" | Acer 22" | Win10
Mobile: Samsung Galaxy Note 5


If I help you, or you just like what I said, rep me by clicking the under my post
carnageX is offline   Reply With Quote
Old 02-14-2014, 06:44 AM   #3 (permalink)
Newb Techie
 
Join Date: Feb 2014
Location: Netherlands
Posts: 2
Default Re: Printer Script doesn't work

I found what i did wrong.

I tried to add a inkjet printer with the universal pcl 6 driver from HP.
After replacing it with the original driver the script worked.

Thanks Carnagex for the fast reply.
poseidon is offline   Reply With Quote
Old 02-14-2014, 09:07 AM   #4 (permalink)
Private Joker
 
carnageX's Avatar
 
Join Date: Feb 2007
Location: South Dakota
Posts: 24,515
Default Re: Printer Script doesn't work

No problem, glad you got it working.
__________________
Laptop: MSI GT70 2OC-059us | i7-4700MQ | 16GB | GTX 770m | 500GB SSD / 750GB HDD | 17.3" | Win10 Pro
Desktop: 4690k | 12GB g.Skill RipJaws | GTX 970 | 520hx | Z87X-UD4H | Corsair Vengeance C70 | Corsair H110 | Acer 25" | Acer 22" | Win10
Mobile: Samsung Galaxy Note 5


If I help you, or you just like what I said, rep me by clicking the under my post
carnageX is offline   Reply With Quote
Reply

Tags
printer, script

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
logon script printer matt8391 Computer Networking and Internet Hardware 1 06-22-2009 10:44 AM
Doesn't run from battery/battery doesn't charge coolshmo Laptops and Notebooks 2 07-18-2008 03:00 AM
How to work with partitions in Windows Vista / XP when Disk Management doesn’t work Osiris Tips, Tricks & Tutorials 0 04-12-2007 04:16 PM
Printer Script jk0864 Computer Networking and Internet Hardware 0 06-06-2006 05:00 PM
Grabing printers and printer info via a script Ibbz Programming 0 01-03-2005 09:55 AM



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 03:43 AM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.