Solved

Printer Orientation

Posted on 2012-03-26
5
1,097 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

635 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