Solved

Printer Orientation

Posted on 2012-03-26
5
1,087 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create Consolidation Sheet 3 51
A Table within a User Form 24 78
need assistance with a VBscript 3 55
INSERT value into first row in 75 workbooks 8 38
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 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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

751 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