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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problems rassing

Status
Not open for further replies.

JamesATL

IS-IT--Management
Jun 25, 2002
4
US
Does anyone know why I'm having problems passing these parameters to RUNDLL32? Thanks -James

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

Dim strPrinterName
Dim strPrinterDriver
Dim strPrinterPort
Dim strPrinterInf
Dim AddPrinter


strPrinterName = "SERO-LJ1 - Servicing Department HP LaserJet 4000"
strPrinterDriver = "HP LaserJet 4000 Series PCL"
strPrinterPort = "SERO-LJ1"
strPrinterInf = "C:\WINDOWS\INF\ntprint.inf"

AddPrinter = WshShell.Run ("RUNDLL32 PRINTUI.DLL,PrintUIEntry /b strPrinterName /m strPrinterDriver /r strPrinterPort")
 
JamesATL,

The line you were using included the variables as strings, not variables. Change to the following.

fengshui_1998


AddPrinter = WshShell.Run ("RUNDLL32 PRINTUI.DLL,PrintUIEntry /b" & strPrinterName & " /m " & strPrinterDriver & " /r strPrinterPort")
 
Hahaha, wow, what a newbie mistake. =)

So here's the final code if anyone else runs into this problem.

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

Dim strPrinterName
Dim strPrinterDriver
Dim strPrinterPort
Dim strPrinterInf
Dim AddPrinter


strPrinterName = """SERO-LJ1 - Servicing Department HP LaserJet 5Si"""
strPrinterModel = """HP LaserJet 4000 Series PCL"""
strPrinterPort = """SERO-LJ1"""
strPrinterInf = """C:\WINDOWS\INF\ntprint.inf"""

WScript.Echo "Printer Name: " & strPrinterName & vbCRLF & "PrinterPort: " & strPrinterPort & vbCRLF & "Printer Driver: " & strPrinterModel & vbCRLF & "Printer INF: " & strPrinterInf

AddPrinter = WshShell.Run ( "RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /q /b " & strPrinterName & " /f " & strPrinterInf & " /m " & strPrinterModel & " /r " & strPrinterPort )

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top