Solved

Printer Commands

Posted on 2012-03-19
23
533 Views
Last Modified: 2012-04-16
I need to put the following initialiazation string in the "Begin Print Job" field as per attachment.

<1B>%-12345X@PJL<20>ENTER<20>LANGUAGE=POSTSCRIPT<0A01>M%PS-Adobe<0A>(LexForm)run<20>Bs<0A20>

I already have a little script to do the separator page. How can I modify it

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

Set colInstalledPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
      ObjPrinter.SeparatorFile = "\\aupriprint02\lexform\lexform.sep"
      objPrinter.Put_
Next

Wscript.echo "Done"
Printer.bmp
0
Comment
Question by:Bianchi928
  • 13
  • 10
23 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 37742860
Have you looked at the objPrinter properties?  Is there a property that can be associated with the Begin Print Job data?  If so, then assign your string to that property.
0
 

Author Comment

by:Bianchi928
ID: 37744559
Hi,

I've already done all of that and there wasn't any, hence my question.

Cheers
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37744778
Have you tried SendKeys?
0
 

Author Comment

by:Bianchi928
ID: 37744830
No never..Can you please eleborate on how to ? Thanks
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37745162
Here is a link to an EE article/tutorial (in Jscript):
http://www.experts-exchange.com/Programming/System/Windows__Programming/A_2449-Using-SendKeys-to-Automate-Repetitive-Tasks.html

Basically, you use the AppActivate and SendKeys methods of a Wscript.Shell object.

Your job is made a bit easier, since, you can use Alt+J ("%J") key combination to set focus to the Begin Print Job textbox control.
0
 

Author Comment

by:Bianchi928
ID: 37745369
Hi there !!

You're definitely on the right track. I need a kick start . Just give me a few start lines for my VBscript on how to AppActivate the "Begin Print Job" box. I think I understand how to send the keys then.

Thanks heaps
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37745483
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "U119c2-CostartDocuments Properties"
WshShell.SendKeys "%J"
WshShell.SendKeys "<1B>%-12345X@PJL<20>ENTER<20>LANGUAGE=POSTSCRIPT<0A01>M%PS-Adobe<0A>(LexForm)run<20>Bs<0A20>"

Open in new window

0
 

Author Comment

by:Bianchi928
ID: 37745541
Okay..I can see what you mean now. How does "%J" related to "Begin Print Job". I ran the little script you gave me and nothign is written to "Begin Print Job".

Thanks
Cheers
0
 

Author Comment

by:Bianchi928
ID: 37745571
I tried the following  - no sucess

Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "Printers and Faxes"
Wscript.sleep 100
WshShell.AppActivate "U119c2-CostartDocuments"
Wscript.sleep 100
WshShell.AppActivate "U119c2-CostartDocuments Properties"
Wscript.sleep 100
WshShell.AppActivate "Printer Commands"
Wscript.sleep 100
WshShell.SendKeys "%J"
WshShell.SendKeys "<1B>%-12345X@PJL<20>ENTER<20>LANGUAGE=POSTSCRIPT<0A01>M%PS-Adobe<0A>(LexForm)run<20>Bs<0A20>"
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37745704
The %J string is the equivalent to you pressing Alt+J at the dialog.  It should set focus to the textbox to the right of the Begin Print Job label.

Why are there so many AppActivate methods being invoked?  The activation of the dialog must immediately precede any SendKeys methods.

What do you see when my script ran?

What causes your dialog box to appear?
0
 

Author Comment

by:Bianchi928
ID: 37745726
Okay..I have a script called zzz.vbs which contains (your code) and I've copied it on to the printer server . There's a printer called U119c2-CostartDocuments. When I ran your script, I can see wscript running in Task Manager. It doesn't come with any error at all. When I check
U119c2-CostartDocuments Properties, Printer Commands, Begin Print Job, there's nothing in this field.



Cheers
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 45

Expert Comment

by:aikimark
ID: 37746800
How do you open the properties dialog window?

My code assumes this dialog window is open.
0
 

Author Comment

by:Bianchi928
ID: 37749195
Usually , I will just right click on U119c2-CostartDocuments.
0
 

Author Comment

by:Bianchi928
ID: 37749198
and select Properties
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37750426
What happens when you run the script after opening the dialog window?
0
 

Author Comment

by:Bianchi928
ID: 37750486
Select U119C2-CostarDocuments

I right click the Properties, Click Printer Commands and the Begin Print Job box is focussesd
Ran the script , nothing happens.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37750816
If you are on the correct tab, does pressing Alt+J set the focus on the correct textbox?
0
 

Author Comment

by:Bianchi928
ID: 37750838
I've done that too and still nothing.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37753010
>>still nothing
Does that mean that if the cursor is in another textbox on that dialog tab, it will not change focus to the Begin Print Job textbox?

If we can't get the sendkeys to work, the only other solution path I can think of is to look at the registry as a place where these strings are stored.
0
 

Author Comment

by:Bianchi928
ID: 37754450
I even tried that..Have the the focus to another field and then using ALT J. It does focus back to Begin Print Job. I alkso checked and there's any registry entried for that.

Cheers
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37755056
What kind of device is this?
0
 

Accepted Solution

by:
Bianchi928 earned 0 total points
ID: 37755306
Anyway, I've already cut and paste the init strings for all the printers. It had to be done urgently.
0
 

Author Closing Comment

by:Bianchi928
ID: 37850404
That's the only way I could fix the problem
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now