Solved

Printer Orientation

Posted on 2012-03-26
5
1,077 Views
Last Modified: 2012-03-28
I want to change a list fo printers from Portrait to Landscape...I have this code

I need some help here

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

Set colInstalledPrinters =  objWMIService.ExecQuery("SELECT * FROM Win32_PrinterConfiguration where name like '%u104c2%")

wscript.echo

For Each objPrinter in colInstalledPrinters
      wscript.echo ObjPrinter.Orientation
      ObjPrinter.Orientation =
      objPrinter.Put_
Next

Wscript.echo "Done"
0
Comment
Question by:Bianchi928
  • 2
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37772437
0
 

Author Comment

by:Bianchi928
ID: 37773614
I've seen that link prior to my question. If I set ObjPrinter.Orientation = 2 and then check what the result is..it still shows protrait..That's what I don't understand

Cheers
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37775109
sorry. then I do not have any suggestions
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 200 total points
ID: 37780064
The WMI Printer collection is mostly read only including the Orientation.  This value cannot be set with the Put command.  If this is all being run on one machine, you could install setprinter and use it to change the orientation.  (Download and install the Windows 2003 Resource kit from http://www.microsoft.com/download/en/details.aspx?id=17657 and install the kit.  This will put setprinter on your machine.)  Then you could run a script like this:

strComputer = "."
Set objShell = CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery("SELECT * FROM Win32_PrinterConfiguration where name like '%u104c2%'")

For Each objPrinter in colInstalledPrinters
	objShell.Run ("setprinter.exe """ & objPrinter.Name & """ 2 ""pDevMode=dmOrientation=2""")	
Next

Wscript.echo "Done"

Open in new window


-Bear
0
 

Author Closing Comment

by:Bianchi928
ID: 37780083
That's all I wanted. You'ev got the points

Cheers
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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