Jump to content

Seeking Printer Install Solution


Recommended Posts

Hello All,

I've been searching the forums for a printing solution that will meet my needs... but, most of the scripts I have been able to find are related to a 'Print Server' which is NOT possible here....

My situation is this.... I support 30+ PC's, we use IP printing (about 9 printers total)...

I am looking to create, or modify an existing script, that will allow me to automate the process of installing these printers to the machines.

Currently I am just doing the old manual 'Start > Printers and Faxex > ....' manually for each printer that needs to be installed.

Does anyone have anything 'fancy' out there that I could use? OR any good ideas for this situation?

Thanks!

--jeff

Link to comment
Share on other sites

Yeah I have something; I'll take your 30 PCs and raise you 3600. This didn't eliminate having to visit each PC but it made life a heck of a lot easier not to mention less prone to errors. What I did was package the drivers and the AutoIT script together using powerarchiver. Turned it into a self-executing archive and had it run the FastPrinterInstaller.exe file after it was done extracting. This helped make a tidy little package we put on our flash drives.

I comment the hell out of my code, you should be able to figure out how to modify it for your environment.

Good luck, man!

WiSp

#cs ----------------------------------------------------------------------------

 Author:  WiSp
 Organization: ** Removed **
 Script Function:
    Automatically install the Canon and Ricoh series printers.
        Models Covered:
            Canon iR2220/iR3320 PCL5e
            Canon iR2270/iR2870 PCL5e
            Canon iR3570/iR4570 PCL5e
            Canon iR5070 PCL5e
            Canon iR5000-6000 PCL5e
            Ricoh Aficio 1515 PCL 6

#ce ----------------------------------------------------------------------------

; Script Start

#Include <GuiListView.au3>
#include <GUIConstants.au3>

;#NoTrayIcon

Dim $PrinterDriver = ""
Dim $PrinterIP = ""
Dim $PrinterModel = ""
Dim $PrinterFriendlyName = ""
Dim $PrinterFriendlyNameAndIP = ""
Dim $PrinterMakeDefault = "0"

Dim $CanonDriver = "C:\drivers\Canon Printer-Copiers\win2k_xp\pcl5e_5c\P52KUSAL.INF"
Dim $RicohDriver = "C:\drivers\Ricoh 1515\Win2000\OEMSETUP.INF"
Dim $WindowsDriver = ""



; Check to see if the OS it's being run on is Windows 2K or Windows XP, all others fail.
$OSVer = @OSVersion
If $OSVer <> "Win_XP" Then
    If $OSVer <> "Win_2000" Then
        MsgBox (48, "Wrong OS Version", "Sorry, you are running " & $OSVer & ", this program is for Windows 2000 or XP only.")
        Exit
    EndIf
EndIf

#Region ### START GUI section ###
$Form1_1 = GUICreate("Printer Installer", 211, 217, -1, -1)
$TextBox1 = GUICtrlCreateInput("123.123.", 8, 24, 193, 21); textbos with first to IP octets
$List1 = GUICtrlCreateList("", 8, 72, 193, 97)
; NOTE: The list is the actualy driver name as it would be found if you were selecting it from a list of drivers.
; It is trimmed later to make the name more friendly
GUICtrlSetData(-1, "Canon iR2220/iR3320 PCL5e|Canon iR2270/iR2870 PCL5e|Canon iR3570/iR4570 PCL5e|Canon iR5070 PCL5e|Canon iR5000-6000 PCL5e|Ricoh Aficio 1515 PCL 6", "Canon iR2220/iR3320 PCL5e")
$Button1 = GUICtrlCreateButton("&Install Printer", 8, 184, 121, 25, 0)
$Button2 = GUICtrlCreateButton("&Cancel", 136, 184, 65, 25, 0)
$Label1 = GUICtrlCreateLabel("Printer IP Address:", 8, 8, 91, 17)
$Label2 = GUICtrlCreateLabel("Select Printer Model:", 8, 56, 102, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Make Default", 112, 160, 89, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END GUI section ###

; Hit "right" arrow key to get the cursor in a position to just type the last two
; octets of the IP address.
Send ("{RIGHT}")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            $PrinterIP = GUICtrlRead ( 3 )
            $PrinterModel = GUICtrlRead ( 4 )
                
; Find out if the Make Default checkbox was checked, this could be made cleaner but it works so I'm not touching it.
                If GUICtrlRead ( 9 ) = 1 Then
                    $PrinterMakeDefault = "/y"
                EndIf
                
; If the model contains canon or ricoh, set the correct driver path
                If StringInStr($PrinterModel, "Canon") Then
                    $PrinterDriver = $CanonDriver
                ElseIf StringInStr($PrinterModel, "Ricoh") Then
                    $PrinterDriver = $RicohDriver
                EndIf
            
            GUISetState(@SW_HIDE)
            ExitLoop
        Case $Button2; Cancel button
            Exit
        Case $GUI_EVENT_CLOSE; Windows "X" button
            Exit
    EndSwitch
WEnd


; Create the printername and IP address combo to make a unique name. We replace the 
; "/" with a "-" because WinXP which doesn't allow "/" to be in port names.
; eg. "Canon iR3570-iR4570 (123.12)"
$PrinterTemp = StringTrimRight($PrinterModel, 5) & '(' & StringTrimLeft ($PrinterIP, 8) & ')'
$PrinterFriendlyNameAndIP = StringReplace($PrinterTemp, "/", "-")



#cs
RUN AS SET needs a permanant local Administrator account

*** Keep both commented out to run as the local user's privs. ***
#ce

; Uncomment to run on Local Adminstrator Account on a PC
;RunAsSet ("Administrator", @ComputerName, "PASSWORD_HERE")

; Uncomment to run as an Admin account on AD
;RunAsSet ("AD_ACCOUNT_HERE", "DOMAIN_HERE", "PASSWORD_HERE")


; Run the Add Printer Wizard
Run(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /il', "",@SW_HIDE)


If $OSVer = "WIN_XP" Then
    WinWaitActive ("Add Printer Wizard", "Welcome to the Add Printer Wizard")
    ControlClick ("Add Printer Wizard", "", 12324); Click Next>
    
    WinWaitActive ("Add Printer Wizard", "Select the option that describes the printer you want to use")
    ControlClick ("Add Printer Wizard", "", 3510); Select Local Pritner
    ControlCommand ("Add Printer Wizard", "Automatically detect and install my Plug and Play printer", 4665, "UnCheck", ); Uncheck AutoDetect
    ControlClick ("Add Printer Wizard", "Select the option that describes the printer you want to use",12324); Click Next>
    
    WinWaitActive ("Add Printer Wizard", "Select the port you want your printer to use") 
    ControlCommand ("Add Printer Wizard", "Create a new port", 4558, "Check", ""); We want to create a new port
    ControlCommand ("Add Printer Wizard", "Create a new port", 4557, "SelectString", 'Standard TCP/IP Port'); look for Standard TCP/IP port
    ControlClick ("Add Printer Wizard", "", 12324); Click Next>

ElseIf $OSVer = "WIN_2000" Then
    WinWaitActive( "Add Printer Wizard" )
    ControlClick ( "Add Printer Wizard", "", 12324); Click Next>
        
; Select Local printer, uncheck the Auto Detect Checkbox
    WinWaitActive( "Add Printer Wizard", "If the printer is directly attached to your computer")
    Send("!L")
;ControlCommand ( "Add Printer Wizard", "", 4559, "Check"); Check "Local printer"
    ControlCommand ( "Add Printer Wizard", "", 4665, "UnCheck"); UnCheck Automatically detect
    ControlClick ("Add Printer Wizard", "", 12324); Click Next>
    
; Select a standard port or create a new port, we create a new port and select "Standard TCP/IP"
    WinWaitActive( "Add Printer Wizard", "Select the port you want your printer to use")
    ControlClick ( "Add Printer Wizard", "", 4558); Create new port select
    $ret = ControlCommand ("Add Printer Wizard", "", 4557, "FindString", 'Standard TCP/IP Port')
    ControlCommand("Add Printer Wizard","", 4557, "SetCurrentSelection", $ret)
    ControlClick ("Add Printer Wizard", "", 12324); Click Next>
Else
    MsgBox (64, "Error", "Unhandled Exception, notify WiSp of the helpdesk xxx-xxx-xxxx")
    Exit
EndIf


; Enter the IP address and Name of the printer, these are taken from variable input boxes at the beginning
WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "You use this wizard to add a port for a network printer")
    ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12324); Click Next>

WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "Enter the Printer Name or IP address")
    ControlClick ( "Add Standard TCP/IP Printer Port Wizard", "", 1000)
    Send ($PrinterIP); enter the printer's IP address
    Send ("{TAB}"); switch to port name field
    Send ("{HOME}{DEL 20}"); Backspace over the port name
    Send ($PrinterFriendlyNameAndIP); Enter the friendly port name
    ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12324); Click Next>


; Finish off the add _port_ wizard and then return to the add _printer_ wizard
WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "You have selected a port with the following characteristics.")
    ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12325); Click finish button

; Kill the Add Printer wizard, we added our port already, we don't need it this program anymore.
WinWaitActive( "Add Printer Wizard", "Select the manufacturer and model of your printer")
    ControlClick ( "Add Printer Wizard", "", 2); Click Cancel button
    
;;; Grand Finale!  Install the damn thing!
RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "' & $PrinterFriendlyNameAndIP & '" /if /f "' & $PrinterDriver & '" /r "' & $PrinterFriendlyNameAndIP & '" /m "' & $PrinterModel & '"', "",@SW_HIDE)


; Makes the printer default if the checkbox is checked. /y means set default, /n is the friendly name of the printer
If ($PrinterMakeDefault = "/y") Then
    Run(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /y /n "' & $PrinterFriendlyNameAndIP & '"', "",@SW_HIDE)
EndIf


#cs THIS IS BROKE, need to fix!
; We will try to set the default printer for all users on a system if the "make default" checkbox is checked
If ($PrinterMakeDefault = "/y") Then
    $var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
    If $OSVer = "WIN_XP" Then
        RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", "REG_SZ", $var)
        msgbox (0, "XP dev", $var)
    ElseIf $OSVer = "WIN_2000" Then
        RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Windows", "device", "REG_SZ", $var)
        msgbox (0, "2k dev", $var)
    EndIf
EndIf
#ce

; Find out if they would like to run another loop of the printer installer
$ButtonPushed = Msgbox (36, "Install Another Printer?", "Would you like to install another printer? This box will automatically close in 15 seconds", 15)
If ($ButtonPushed = 6) Then
    Run(@ComSpec & " /c " & 'c:\drivers\FastInstallPrinter.exe', "",@SW_HIDE)
EndIf
Edited by WiSp
Link to comment
Share on other sites

I looked at that, it works only in WindowsXP. I have a mixed Windows 2000/Windows XP environment as do many businesses and organizations.

I didn't say it'd be the end all be all solution to the problem... Although a quick OS check would allow you to use a quick and easy solution for XP and then a more complicated one for 2000 since a simple one doesn't exist... *shrug*

BTW, why don't you use ControlSetText here instead of Send?

WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "Enter the Printer Name or IP address")
    ControlClick ( "Add Standard TCP/IP Printer Port Wizard", "", 1000)
    Send ($PrinterIP); enter the printer's IP address
    Send ("{TAB}"); switch to port name field
    Send ("{HOME}{DEL 20}"); Backspace over the port name
    Send ($PrinterFriendlyNameAndIP); Enter the friendly port name
    ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12324); Click Next>
Edited by exodius
Link to comment
Share on other sites

I didn't say it'd be the end all be all solution to the problem... Although a quick OS check would allow you to use a quick and easy solution for XP and then a more complicated one for 2000 since a simple one doesn't exist... *shrug*

BTW, why don't you use ControlSetText here instead of Send?

WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "Enter the Printer Name or IP address")
    ControlClick ( "Add Standard TCP/IP Printer Port Wizard", "", 1000)
    Send ($PrinterIP); enter the printer's IP address
    Send ("{TAB}"); switch to port name field
    Send ("{HOME}{DEL 20}"); Backspace over the port name
    Send ($PrinterFriendlyNameAndIP); Enter the friendly port name
    ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12324); Click Next>
Because I'm a newbie at this stuff and didn't know I could do that :"> I think I'm doing pretty good for having no formal training and have only picked up this autoit stuff in the past couple weeks.
Link to comment
Share on other sites

This is great stuff guys... thanks to all!

Keep it coming!

WiSp, your utility is almost *exactly* what I was looking for... I'm not very good at coding 'yet', but I'm trying to go through and see how I may be able to customize this program for our exact needs... thank you for sharing this code!

Edited by Jeffro11821
Link to comment
Share on other sites

Hey sweet i just made a program that does exactly this ;)

1. Basically enter in the IP printer stuff into the printer part of the gui

2. add computers to list ex: compname not \\compname

3. sit back and relax

Here is the program: Printer Borger

Any questions just ask!

Do you have the source code? I'd like to take a look at the networking stuff you used.

Link to comment
Share on other sites

Do you have the source code? I'd like to take a look at the networking stuff you used.

Hey WiSp,

I know your question was directed to/at DDRBoxman, but I just wanted to tell you that I am working on modifying your printer solution ...

I am wanting to get rid of the need to memorize printer IP address's... so, for my department... I want to take your 'Printer Model' selection box and modify it a bit so that the box gives us 'friendly' names and the printer's IP address is automatically determined.

For example... instead of choosing 'Cannon 5' and typing in the IP address....

I want to modify my version of your app so that you have the option to click on a more detailed description 'Cannon 5 - 2nd Floor MailRoom' , and when make this choice... the IP address is 'hard coded' in.

I only have about 12 printers that I support... a lot of redundant models... so that this shouldn't be that hard to do, right? I'm just saying.. this may not scale all that well to a larger environment...

Do you have any idea on a better way to handle this??

I am just trying to create a way so that there is no need to memorize any IP's, any admin can run the tool and easily select the correct printer in our dept, get the correct driver and IP address in a snap....

Thank you again for sharing.. this code has helped me learn a LOT.

--jeff

Edited by Jeffro11821
Link to comment
Share on other sites

Hey WiSp,

I know your question was directed to/at DDRBoxman, but I just wanted to tell you that I am working on modifying your printer solution ...

I am wanting to get rid of the need to memorize printer IP address's... so, for my department... I want to take your 'Printer Model' selection box and modify it a bit so that the box gives us 'friendly' names and the printer's IP address is automatically determined.

For example... instead of choosing 'Cannon 5' and typing in the IP address....

I want to modify my version of your app so that you have the option to click on a more detailed description 'Cannon 5 - 2nd Floor MailRoom' , and when make this choice... the IP address is 'hard coded' in.

I only have about 12 printers that I support... a lot of redundant models... so that this shouldn't be that hard to do, right? I'm just saying.. this may not scale all that well to a larger environment...

Do you have any idea on a better way to handle this??

I am just trying to create a way so that there is no need to memorize any IP's, any admin can run the tool and easily select the correct printer in our dept, get the correct driver and IP address in a snap....

Thank you again for sharing.. this code has helped me learn a LOT.

--jeff

Hmm, well, I suppose you could use the part in the GUI section that chooses the driver path (Canon or Richo) and also assign IP addresses from there. You can use koda to make our own GUI or just comment out the lines for the IP address block from my code until you become more comfortable with making your own.

In any case, you'd need another variable called $PrinterChoice which would write the selected item when you pushed the "Install Printer" button. Then your IF/ELSE statement (example below) would do the heavy lifting. I think the "right" thing to use would be a "switch/case" statement but I'm not very comfortable (read newbie-ish) with those. If anyone else here with more programming experience can explain how to write a case statement that is easy to understand for programming newbies, please do, I'll be checking back.

If StringInStr($PrinterChoice, "Canon 5000 - 2nd floor") Then
    $PrinterModel = "Canon iR5000 PCL6" ; Driver name found in the .ini file
    $PrinterDriver = $CanonDriver
    $IPAddress = 12.34.56.78
ElseIf StringInStr($PrinterChoice, "Canon 2000 - 9th floor") Then
    $PrinterModel = "Canon iR2000/3000 PCL6" ; Driver name found in the .ini file
    $PrinterDriver = $CanonDriver
    $IPAddress = 87.23.56.79
ElseIf StringInStr($PrinterChoice, "Canon 2300 - 1st floor") Then
... more stuff ...
EndIf
Link to comment
Share on other sites

  • 1 year later...

I have tried editing this script for my use, but I keep getting random error messages like 'WEnd wihout While' and 'EndIf without If', even though they're there, any ideas?

#cs ----------------------------------------------------------------------------

Author: WiSp

Modified By: Ryan Stephens

Script Function:

Automatically install a RICOH Photocopier.

Models Covered:

RICOH Aficio 1075

RICOH Aficio 1232C

RICOH Aficio 2051

RICOH Aficio 2075 - Business School and Xfi

RICOH Aficio 2090

RICOH Aficio Color5560

RICOH Pro 1106EX

#ce ----------------------------------------------------------------------------

; Script Start

#Include <GuiListView.au3>

#include <GUIConstants.au3>

;#NoTrayIcon

Dim $PrinterDriver = ""

Dim $PrinterIP = ""

Dim $PrinterModel = ""

Dim $PrinterFriendlyName = ""

Dim $PrinterFriendlyNameAndIP = ""

Dim $PrinterMakeDefault = "0"

Dim $1075Driver = "C:\Drivers\1075_RPCS\RC15E12K.INF"

Dim $1232CDriver = "C:\Drivers\1232C_RPCS\RC82E12K.INF"

Dim $2075Driver = "C:\Drivers\2075_RPCS\RC20E12K.INF"

Dim $2051Driver = "C:\Drivers\2051_RPCS\RC20E12K.INF"

Dim $2090Driver = "C:\Drivers\2090_RPCS\RC19E12K.INF"

Dim $5560EXDriver = "C:\Drivers\5560_RPCS\RC8DE12K.INF"

Dim $1106EXDriver = "C:\Drivers\1106EX_RPCS\RC68E12K.INF"

Dim $WindowsDriver = ""

; Check to see if the OS it's being run on is Windows 2K or Windows XP, all others fail.

$OSVer = @OSVersion

If $OSVer <> "Win_XP" Then

If $OSVer <> "Win_2000" Then

MsgBox (48, "Wrong OS Version", "Sorry, you are running " & $OSVer & ", this program is for Windows 2000 or XP only.")

Exit

EndIf

EndIf

#Region ### START GUI section ###

$Form1_1 = GUICreate("RICOH Photocopier Installer", 211, 217, -1, -1)

$TextBox1 = GUICtrlCreateInput("144.173.", 8, 24, 193, 21); textbos with first to IP octets

$List1 = GUICtrlCreateList("", 8, 72, 193, 97)

; NOTE: The list is the actualy driver name as it would be found if you were selecting it from a list of drivers.

; It is trimmed later to make the name more friendly

GUICtrlSetData(-1, "RICOH Aficio 1075|RICOH Aficio 1232C|RICOH Aficio 2051|RICOH Aficio 2075 (BS)|RICOH Aficio 2075 (Xfi)|RICOH Aficio 2090|RICOH Aficio Color5560|RICOH Pro 1106EX RPCS", "RICOH Aficio 2075 RPCS (BS)")

$Button1 = GUICtrlCreateButton("&Install", 8, 184, 121, 25, 0)

$Button2 = GUICtrlCreateButton("Cancel", 136, 184, 65, 25, 0)

$Label1 = GUICtrlCreateLabel("Photocopier IP Address:", 8, 8, 91, 17)

$Label2 = GUICtrlCreateLabel("Select Model:", 8, 56, 102, 17)

$Checkbox1 = GUICtrlCreateCheckbox("Make Default", 112, 160, 89, 17)

GUISetState(@SW_SHOW)

#EndRegion ### END GUI section ###

; Hit "right" arrow key to get the cursor in a position to just type the last two

; octets of the IP address.

Send ("{RIGHT}")

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Button1

$PrinterChoice = GUICtrlRead ( 3 )

; Find out if the Make Default checkbox was checked, this could be made cleaner but it works so I'm not touching it.

If GUICtrlRead ( 9 ) = 1 Then

$PrinterMakeDefault = "/y"

EndIf

; If the model contains canon or ricoh, set the correct driver path

If StringInStr($PrinterChoice, "RICOH Aficio 1075") Then

$PrinterModel = "RICOH Aficio 1075 RPCS" ; Driver name found in the .ini file

$PrinterDriver = $1075Driver

$IPAddress = 144.173.60.2

If StringInStr($PrinterChoice, "RICOH Aficio 1232C") Then

$PrinterModel = "RICOH Aficio 1232C RPCS" ; Driver name found in the .ini file

$PrinterDriver = $1232CDriver

$IPAddress = 144.173.60.1

If StringInStr($PrinterChoice, "RICOH Aficio 2051") Then

$PrinterModel = "RICOH Aficio 2051 RPCS" ; Driver name found in the .ini file

$PrinterDriver = $2051Driver

$IPAddress = 144.173.220.108

If StringInStr($PrinterChoice, "RICOH Aficio 2075 (BS)") Then

$PrinterModel = "RICOH Aficio 2075 RPCS (BS)" ; Driver name found in the .ini file

$PrinterDriver = $2075Driver

$IPAddress = 144.173.220.107

If StringInStr($PrinterChoice, "RICOH Aficio 2075 (Xfi)") Then

$PrinterModel = "RICOH Aficio 2075 RPCS (Xfi)" ; Driver name found in the .ini file

$PrinterDriver = $2075Driver

$IPAddress = 144.173.60.32

If StringInStr($PrinterChoice, "RICOH Aficio 2090") Then

$PrinterModel = "RICOH Aficio 2090 RPCS" ; Driver name found in the .ini file

$PrinterDriver = $2090Driver

$IPAddress = 144.173.220.113

If StringInStr($PrinterChoice, "RICOH Aficio Color5560") Then

$PrinterModel = "RICOH Aficio Color5560 RPCS" ; Driver name found in the .ini file

$PrinterDriver = $5560Driver

$IPAddress = 144.173.220.139

ElseIf StringInStr($PrinterChoice, "RICOH Pro 1106EX") Then

$PrinterModel = "RICOH Pro 1106EX RPCS" ; Driver name found in the .ini file

$PrinterDriver = $1106EXDriver

$IPAddress = 144.173.220.222

EndIf

GUISetState(@SW_HIDE)

ExitLoop

EndSwitch

WEnd

#cs

RUN AS SET needs a permanant local Administrator account

*** Keep both commented out to run as the local user's privs. ***

#ce

; Uncomment to run on Local Adminstrator Account on a PC

RunAsSet ("admin", @ComputerName, "ex44pu")

; Uncomment to run as an Admin account on AD

;RunAsSet ("AD_ACCOUNT_HERE", "DOMAIN_HERE", "PASSWORD_HERE")

; Run the Add Printer Wizard

Run(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /il', "",@SW_HIDE)

If $OSVer = "WIN_XP" Then

WinWaitActive ("Add Printer Wizard", "Welcome to the Add Printer Wizard")

ControlClick ("Add Printer Wizard", "", 12324); Click Next>

WinWaitActive ("Add Printer Wizard", "Select the option that describes the printer you want to use")

ControlClick ("Add Printer Wizard", "", 3510); Select Local Pritner

ControlCommand ("Add Printer Wizard", "Automatically detect and install my Plug and Play printer", 4665, "UnCheck", ); Uncheck AutoDetect

ControlClick ("Add Printer Wizard", "Select the option that describes the printer you want to use",12324); Click Next>

WinWaitActive ("Add Printer Wizard", "Select the port you want your printer to use")

ControlCommand ("Add Printer Wizard", "Create a new port", 4558, "Check", ""); We want to create a new port

ControlCommand ("Add Printer Wizard", "Create a new port", 4557, "SelectString", 'Standard TCP/IP Port'); look for Standard TCP/IP port

ControlClick ("Add Printer Wizard", "", 12324); Click Next>

ElseIf $OSVer = "WIN_2000" Then

WinWaitActive( "Add Printer Wizard" )

ControlClick ( "Add Printer Wizard", "", 12324); Click Next>

; Select Local printer, uncheck the Auto Detect Checkbox

WinWaitActive( "Add Printer Wizard", "If the printer is directly attached to your computer")

Send("!L")

;ControlCommand ( "Add Printer Wizard", "", 4559, "Check"); Check "Local printer"

ControlCommand ( "Add Printer Wizard", "", 4665, "UnCheck"); UnCheck Automatically detect

ControlClick ("Add Printer Wizard", "", 12324); Click Next>

; Select a standard port or create a new port, we create a new port and select "Standard TCP/IP"

WinWaitActive( "Add Printer Wizard", "Select the port you want your printer to use")

ControlClick ( "Add Printer Wizard", "", 4558); Create new port select

$ret = ControlCommand ("Add Printer Wizard", "", 4557, "FindString", 'Standard TCP/IP Port')

ControlCommand("Add Printer Wizard","", 4557, "SetCurrentSelection", $ret)

ControlClick ("Add Printer Wizard", "", 12324); Click Next>

Else

MsgBox (64, "Error", "Unhandled Exception, notify Ryan Stephens of Desktop Support Ext:3934")

Exit

EndIf

; Enter the IP address and Name of the printer, these are taken from variable input boxes at the beginning

WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "You use this wizard to add a port for a network printer")

ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12324); Click Next>

WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "Enter the Printer Name or IP address")

ControlClick ( "Add Standard TCP/IP Printer Port Wizard", "", 1000)

Send ($IPAddress); enter the printer's IP address

ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12324); Click Next>

; Finish off the add _port_ wizard and then return to the add _printer_ wizard

WinWaitActive( "Add Standard TCP/IP Printer Port Wizard", "You have selected a port with the following characteristics.")

ControlClick ("Add Standard TCP/IP Printer Port Wizard", "", 12325); Click finish button

; Kill the Add Printer wizard, we added our port already, we don't need it this program anymore.

WinWaitActive( "Add Printer Wizard", "Select the manufacturer and model of your printer")

ControlClick ( "Add Printer Wizard", "", 2); Click Cancel button

;;; Grand Finale! Install the damn thing!

RunWait(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /b "' & $PrinterModel & '" /if /f "' & $PrinterDriver & '" /r "' & $IPAddress & '" /m "' & $PrinterModel & '"', "",@SW_HIDE)

; Makes the printer default if the checkbox is checked. /y means set default, /n is the friendly name of the printer

If ($PrinterMakeDefault = "/y") Then

Run(@ComSpec & " /c " & 'rundll32 printui.dll PrintUIEntry /y /n "' & $PrinterModel & '"', "",@SW_HIDE)

EndIf

#cs THIS IS BROKE, need to fix!

; We will try to set the default printer for all users on a system if the "make default" checkbox is checked

If ($PrinterMakeDefault = "/y") Then

$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")

If $OSVer = "WIN_XP" Then

RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", "REG_SZ", $var)

msgbox (0, "XP dev", $var)

ElseIf $OSVer = "WIN_2000" Then

RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Windows", "device", "REG_SZ", $var)

msgbox (0, "2k dev", $var)

EndIf

EndIf

#ce

; Find out if they would like to run another loop of the printer installer

$ButtonPushed = Msgbox (36, "Install Another Photocopier?", "Would you like to install another Photocopier? This box will automatically close in 15 seconds", 15)

If ($ButtonPushed = 6) Then

Run(@ComSpec & " /c " & 'c:\drivers\FastInstallPrinter.exe', "",@SW_HIDE)

EndIf

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...