Jump to content

RunWait PrintUIEntry


Recommended Posts

When I run this I get 'The arguments are invalid'. Can someone tell me why?

RunWait(@ComSpec & ' /c rundll32 printui.dll,PrintUIEntry /if /b "Accounting Dept Printer" /f %windir%\inf\ntprint.inf /r "IP_192.168.1.84" /m "HP LaserJet 5Si MX"')

Link to comment
Share on other sites

When I run this I get 'The arguments are invalid'. Can someone tell me why?

RunWait(@ComSpec & ' /c rundll32 printui.dll,PrintUIEntry /if /b "Accounting Dept Printer" /f %windir%\inf\ntprint.inf /r "IP_192.168.1.84" /m "HP LaserJet 5Si MX"')

The syntax looks correct, but have you created the TCP/IP port prior to running this line?
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

You know you have a valid point! :)

Ok, so I've created the port using reg files. I found most of this script in the forum. (been working!) The problem I have is I would like to use $IPaddress varible in

RunWait(@ComSpec & ' /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r $IPAddress /m "HP Laserjet 5Si Mx"')

but it doesn't work. Is this possible?

CODE
;; Stop the Print Spooler service

$IPaddress = InputBox("IP Address", "What is the IP Address?")

RunWait('cmd /c net stop "print spooler"')

;; Right the Registry Values for the IP port

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "Protocol", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "Version", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "HostName", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "HWAddress", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "IPAddress", "REG_SZ",$IPaddress)

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "PortNumber", "REG_DWORD", "00009100")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Community", "REG_SZ", "D3MYST1F!ED")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Enabled", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Index", "REG_DWORD", "00000001")

;; Start the Print Spooler Service

RunWait('cmd /c net start "print spooler"')

RunWait(@ComSpec & ' /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "IP_" & $IPAddress /m "HP Laserjet 5Si Mx"')

Edited by Tigerweld
Link to comment
Share on other sites

I've tried this too and I get 'invalid argument'.

CODE
RunWait(@ComSpec & ' /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "IP_"' & $IPAddress & '" /m "HP Laserjet 5Si Mx"')

Link to comment
Share on other sites

I've tried this too and I get 'invalid argument'.

RunWait(@ComSpec & ' /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "IP_"' & $IPAddress & '" /m "HP Laserjet 5Si Mx"')
This syntax is correct as well. Try running a PrintUIEntry call prior to this one that just installs the driver. I know it sounds redundant, but that is how I have done this in the past. I'm not at work with access to the batch files and I can't recall it from memory, but there is documentation online for PrintUI.dll.
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Huh? You lost me. I thought I was installing the driver with this code? Can you please post an example of what your talking about? Thanks!

This syntax is correct as well. Try running a PrintUIEntry call prior to this one that just installs the driver. I know it sounds redundant, but that is how I have done this in the past. I'm not at work with access to the batch files and I can't recall it from memory, but there is documentation online for PrintUI.dll.

Link to comment
Share on other sites

RunWait(@ComSpec & ' /c rundll32 printui.dll,PrintUIEntry /if /b "Accounting Dept Printer" /f %windir%\inf\ntprint.inf /r "IP_192.168.1.84" /m "HP LaserJet 5Si MX"')

I was having issues on my Vista box at work, but I just tried this at home on my XP SP3 box and it worked perfectly after I setup the IP port. Are you using Vista or XP?

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

RunWait(@ComSpec & ' /c rundll32 printui.dll,PrintUIEntry /if /b "Accounting Dept Printer" /f %windir%\inf\ntprint.inf /r "IP_192.168.1.84" /m "HP LaserJet 5Si MX"')

I was having issues on my Vista box at work, but I just tried this at home on my XP SP3 box and it worked perfectly after I setup the IP port. Are you using Vista or XP?

XP

I found another post and noticed the quotes were different so I modified mine. Once I changed it it worked. Here is all of my code that I've got working so far. I need to go back and make it the default printer and install another printer using an inf file. I'll post it once I'm done. Hopefully I can help someone from getting the headaches I've gotten while working on this. :)

Thanks for you help!

CODE
;; Stop the Print Spooler service

$IPaddress = InputBox("IP Address", "What is the IP Address?")

$PrinterName = InputBox("Printer Name", "What is the printer name?")

dim $PrinterDriver

;dim $PrinterName

dim $PrinterModel

dim $PrinterPortName

$PrinterPortName = "IP_" & $IPaddress

RunWait('cmd /c net stop "print spooler"')

;; Write the Registry Values for the IP port

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "Protocol", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "Version", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "HostName", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "HWAddress", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "IPAddress", "REG_SZ",$IPaddress)

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "PortNumber", "REG_DWORD", "00009100")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Community", "REG_SZ", "D3MYST1F!ED")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Enabled", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Index", "REG_DWORD", "00000001")

;; Start the Print Spooler Service

RunWait('cmd /c net start "print spooler"')

; INSTALL PRINTER

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "' & $PrinterName & '" /if /f "%windir%\inf\ntprint.inf" /r "' & $PrinterPortName & '" /m "HP Laserjet 5Si Mx"', "",@SW_HIDE)

Edited by Tigerweld
Link to comment
Share on other sites

Here is what I have so far. The user is prompt for the ip address of the printer and the model number. I wish I knew enough to use a form with radio buttons instead, but hey, it works!

What the script does: Creates a printer port first, then creates the default printer using the 5Si Mx, naming the printer BANKER INSIGHT. Then it creates another printer using the same port, but using the correct printer driver.(where the user was prompt)

CODE
#include <GUIConstants.au3>

;; Stop the Print Spooler service

$IPaddress = InputBox("IP Address", "What is the IP Address?")

$PrinterType = InputBox("Enter Printer Model","Enter Printer Model, example; 4, 2430, 4000, 4050, 4100, 4200, 4250, 3005")

;$PrinterName = InputBox("Printer Name", "What is the printer name?")

dim $PrinterDriver

;dim $PrinterName

dim $PrinterModel

dim $PrinterINF

dim $PrinterPortName

$PrinterPortName = "IP_" & $IPaddress

;***********************

RunWait('cmd /c net stop "print spooler"')

; Write the Registry Values for the IP port

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "Protocol", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "Version", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "HostName", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "HWAddress", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "IPAddress", "REG_SZ",$IPaddress)

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "PortNumber", "REG_DWORD", "00009100")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Community", "REG_SZ", "D3MYST1F!ED")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Enabled", "REG_DWORD", "00000001")

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_" & $IPaddress, "SNMP Index", "REG_DWORD", "00000001")

;; Start the Print Spooler Service

RunWait('cmd /c net start "print spooler"')

; INSTALL BANKER INSIGHT PRINTER HP Laserjet 5Si Mx

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "BANKER INSIGHT" /if /f "%windir%\inf\ntprint.inf" /r "' & $PrinterPortName & '" /m "HP Laserjet 5Si Mx"', "",@SW_HIDE)

; MAKE BANKER INSIGHT PRINTER DEFAULT PRINTER

RunWait(@ComSpec & " /c " & 'RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "BANKER INSIGHT"')

;RunWait(@ComSpec & " /c " & 'RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "' & $PrinterName) ;use this line to change back to using variable as printerName

Select

Case $PrinterType = "4"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "%windir%\inf\ntprint.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 4"', "",@SW_HIDE)

Case $PrinterType = "2430"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "c:\citrix\printer Drivers\2430\hpc24x0b.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 2430 PCL 5e"', "",@SW_HIDE)

Case $PrinterType = "4000"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "%windir%\inf\ntprint.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 4000 Series PCL6"', "",@SW_HIDE)

Case $PrinterType = "4050"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "%windir%\inf\ntprint.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 4050 Series PCL6"', "",@SW_HIDE)

Case $PrinterType = "4100"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "%windir%\inf\ntprint.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 4100 Series PCL"', "",@SW_HIDE)

Case $PrinterType = "4200"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "c:\citrix\printer Drivers\4200\hpc4200b.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 4200 PCL 5e"', "",@SW_HIDE)

Case $PrinterType = "4250"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "c:\citrix\printer Drivers\4250\hpc4x50b.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet 4250 PCL 5e"', "",@SW_HIDE)

Case $PrinterType = "3005"

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "EXCEL" /if /f "c:\citrix\printer Drivers\3005x\hpc300xb.inf" /r "' & $PrinterPortName & '" /m "HP LaserJet P3005 PCL 5e"', "",@SW_HIDE)

EndSelect

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...