Printer Orientation

Posted on 2012-03-26
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%")


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

Wscript.echo "Done"
Question by:Bianchi928
  • 2
  • 2
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37772437

Author Comment

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

LVL 75

Expert Comment

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

Accepted Solution

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 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""")	

Wscript.echo "Done"

Open in new window


Author Closing Comment

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


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

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

16 Experts available now in Live!

Get 1:1 Help Now