Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Changing paper size

Posted on 2012-03-14
11
Medium Priority
?
1,526 Views
Last Modified: 2012-03-19
I'm running the following on Windows Server 2008 and I'm gettign an error message

Dim Wshshell, setprnwide132, myprinter

Set Wshshell= CreateObject("WScript.Shell")
myprinter = "\\costarprint01\u155c1-CostarDocuments"
setprnwide132 = "setprinter " & """" & myprinter & """" & " 2 " & """" & "pdevmode=dmpapersize=119" & """"

' size = 8 for A3, size 9 for A4 etc.

intRC = WshShell.Run(setprnwide132, 0, TRUE)

if intRC <> 0 then
WScript.Echo "Error returned from Setting the Printer " & intRC
WScript.Quit
End If

Line 9
The system cannot find the file specified

Any idea ?

Thanks
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
  • 6
  • 5
11 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 37722864
Hi, I assume that's because it can't find setprinter.exe.  You'll need to make sure setprinter.exe is in your %path% environments variable paths.  Usually just the system32 folder (or if it's a 32 bit exe, C:\Windows\SysWow64).

Rob.
0
 

Author Comment

by:Bianchi928
ID: 37722885
Okay I've copied setprinter in c:\scripts on the server and modified the code

Dim Wshshell, setprnwide132, myprinter

Set Wshshell= CreateObject("WScript.Shell")
myprinter = "\\costarprint01\u208c2-CostarDocuments"
setprnwide132 = "c:\scripts\setprinter " & """" & myprinter & """" & " 2 " & """" & "pdevmode=dmpapersize=119" & """"

' size = 8 for A3, size 9 for A4 etc.

intRC = WshShell.Run(setprnwide132, 0, TRUE)

if intRC <> 0 then
WScript.Echo "Error returned from Setting the Printer " & intRC
WScript.Quit
End If

It doesn't coem with any erro, but doesn't do any change to the paper size.
I'm running it with admin login
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37722890
If you change
intRC = WshShell.Run(setprnwide132, 0, TRUE)

to
intRC = WshShell.Run("cmd /k " & setprnwide132, 1, True)

do you see any errors during the command execution?

Rob.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Bianchi928
ID: 37722937
Did that and it came with a dos script saying

Set printer on '\\costarprint01\u226c1-CostarDocuments' succeeded.


But after 2 mins comes up with an error box saying


Error returned from Setting the Printer  -1073741510
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 37722977
I think that error just means the command prompt was closed by the user.  Instead of closing the cmomand prompt with the X, type Exit at the prompt and see if that helps.

If that *does* help without error, change cmd /k to cmd /c and it should work.

Rob.
0
 

Author Comment

by:Bianchi928
ID: 37723015
Forgot to mention that it still didn't change the paper size. What I really want to change is:

Right click the printer, select printer properties, preferences , papersize

NExt

Click Advanced, Printing defaults, advanced, paper size

I have nearly 600 printers to do....

Cheers
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37723041
Above this:
intRC = WshShell.Run("cmd /k " & setprnwide132, 1, True)

put this
InputBox "About to run:", "Command", setprnwide132

and then when that comes up, copy and paste that command directly to a command prompt and see if it works.  You'll need to get that working first...

Rob.
0
 

Author Comment

by:Bianchi928
ID: 37723146
That's the result
=================

C:\Users\Administrator.RETAIL>c:\scripts\setprinter "\\costarprint01\u226c3-Cost
arDocuments" 2 "pdevmode=dmpapersize=119"

Set printer on '\\costarprint01\u226c3-CostarDocuments' succeeded.

C:\Users\Administrator.RETAIL>

==================
Still no change to the paper size
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37723286
So looking through the examples here:
http://www.windowsitpro.com/article/tips/jsi-tip-9675-setprinter-exe-is-a-command-line-tool-to-set-configurations-or-states-of-local-or-remote-printers-

one of them is this (which does it for all local printers):
SetPrinter "" 2 "pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4"

so maybe you need to specify more details about the paper size to match your 119 paper size setting.

Also, since it seems to set the "current user" properties, I assume this will only change the "Printing Preferences" settings, and not the "Printing Defaults".

Regards,

Rob.
0
 

Author Closing Comment

by:Bianchi928
ID: 37736582
Got me on the right path with all the tips . Stopping the spooler while running the script got
it to work fine.

Thanks
Cheers
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37739907
Nice find!  I wouldn't have thought to stop the spooler, make the change, then restart it.  Thanks for letting me know.

Rob.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

715 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