Jump to content

Help with a script to create a new print queue


 Share

Recommended Posts

Hello everyone,

I'm trying to build a script to create a new print queue for a specific software called SafeCom.

But i found some problems, for example, the checkbox to auto detect printer sometimes is checked and sometimes is not. See image:

http://img.photobucket.com/albums/v358/Daryon/AutoDetectPrinter_001.jpg

Is there any way i can make sure it is not checked?

I'm also finding in some servers the following, if someone has created a queue before, there are some selections already marked altering the reference of my pointer. I think what i'm trying to do is not possible, maybe i need to create the queue with cmd commands if that's an option.

This is the script, not working fine atm. The sleep commands are just to see the first steps slowly.

; Start the Add Printer GUI

Run("Rundll32 Printui.dll,PrintUIEntry /il")

; Use AutoItSetOption to slow down the typing speed so we can see it

AutoItSetOption("SendKeyDelay", 400)

Sleep(3000)

; Click Next button - t Spanish n English

Send("{ENTER}")

Sleep(3000)

; Select Local Print Queue and click Next

Send("{UP}")

Sleep(3000)

Send("{ENTER}")

Sleep(3000)

; Select the Create New Port option

Send("!C")

Sleep(3000)

; Select The SafeCom PULL Port option

Send("{DOWN}")

Sleep(3000)

; Click Next button

Send("!t")

Sleep(3000)

; Enter the new port name example: ESPULL01

Send("ESPULL01")

; Accept the new port name

Send("{ENTER}")

; Navigate to the OK button

Send("{TAB}")

Send("{TAB}")

Send("{ENTER}")

; Send default password

Send("nimda")

; Click OK

Send("{ENTER}")

; Wait for the wizard to refresh

Sleep(10000)

; Browse for the print Driver

Send("!U")

; Delete the current path A:\

Send("{BACKSPACE}")

Send("{BACKSPACE}")

Send("{BACKSPACE}")

; Write the new path "C:\Archivos de programa\PrintDrivers\HP\UPD\53110527\WS2003x32\PCL5"

Send("C:\Archivos de programa\PrintDrivers\HP\UPD\53110527\WS2003x32\PCL5")

; Click Browse

Send("!m")

; Select the Files

Send("{TAB}")

Send("{TAB}")

Send("{TAB}")

Send("{TAB}")

Send("{TAB}")

; Scroll down the the correct .inf file

Send("{DOWN}")

; Open the File

Send("!A")

; Select Accept

Send("{TAB}")

Send("{ENTER}")

; Wait for the wizard to refresh

Sleep(10000)

; Select the HP UPD 5.3 PCL5 driver

Send("{TAB}")

Send("{TAB}")

Send("{ENTER}")

; Delete the current Printer Name "HP Universal Printing PCL 5 (v5.3)"

For $i = 34 to 0 Step -1

Send("{BACKSPACE}")

Next

; Enter the new queue name

Send("ESPULL01")

; Accept the new name

Send("{ENTER}")

; Accept the same shared name and finish

Send("!t")

Send("!t")

Send("!t")

Send("{ENTER}")

; Wait for the driver and printer queue to be installed

$i=360

Do

$i = $i-1

; check if the spooler process is still active. -1 indicates TRUE to quit the loop

if (ProcessWait("spoolsv.exe",5) >0) Then $i = -1

Until ( $i <= 0)

; Finished!

Thanks a lot.

Best regards

Link to comment
Share on other sites

Thanks hannes08,

I tried prnmngr.vbs

but i'm unable to make it work, i'm not sure if it can create new printer queues, maybe it is just to modify/connect existing ones.

I tried a combination of the following:

@echo off

echo.

echo Creating the new print queue ESPULL01

cd C:\WINDOWS\System32

cscript prncnfg.vbs -t -s localhost -p ESPULL01 -r ESPULL01 -m SafeComPULL -h ESPULL01 +Shared +published +queued -enablebidi

echo Done!

ping localhost -n 4 > nul

Using the command:

cscript prncnfg.vbs -t -s localhost -p ESPULL01 -r ESPULL01 -m SafeComPULL -h ESPULL01

I get this error:

Unable to get the printer configuration ESPULL01 Error 0x80041002 Not found

Operation GetObject

Provider CIMWin32

Description

Win32 Error code

Can you help me with this?

Thank a lot.

Edited by AntonioGNAL
Link to comment
Share on other sites

New attempt, but there's something still missing, any help is really welcome:

@echo off

echo =======================================================================

echo PRINTER INSTALLATION

echo =======================================================================

echo.

echo.

set /p _ip=Enter printer IP:

cls

echo =======================================================================

echo SELECT PRINTER TYPE

ECHO =======================================================================

echo.

echo 1. HP UPD PULL Queue.

echo.

echo x. Exit

echo.

set /p _sel=Enter number:

if "%_sel%" == "1" call goto HPUPD

if "%_sel%" == "x" call goto END

exit

:HPUPD

cd c:\WINDOWS\System32

cscript Prndrvr.vbs -a -m "HP Universal Printing PCL 5 (v5.3)" -v 3 -e "Windows NT x86" -i "C:\Archivos de programa\PrintDrivers\HP\UPD\53110527\WS2003x32\PCL5\hpbuio20l.inf"

pause

cscript prnport.vbs -a -r IP_"%_ip%" -h "%_ip%" -o RAW -n 9100

pause

cscript prnmngr.vbs -a -p "HPUPD" -m "HP Universal Printing PCL 5" -r IP_"%_ip%"

pause

cscript prnmngr.vbs -t -p "HPUPD"

exit

:END

exit

Edited by AntonioGNAL
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...