I am trying to get the default printer, change it, run a print job and change it back. I have done this before, however in this script I have to have Varexplicit set to 0 and this seems to be an issue when setting the printer back to the default. I have to be making somekind of syntax error.
Any ideas as to what is wrong with the script below? If I remove the Varexplicit line and add % signs before and after DefPrinter on the last line it works.
Also, if I remove the % signs in the line
Let>DefPrinter={Copy(%DefPrinter%,1,Pos(",",%DefPrinter%)-1)}
if fails.
------------ Failing Script
Let>VAREXPLICIT=0
//Get the default printer
RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Windows NT\CurrentVersion\Windows,Device,DefPrinter
Let>DefPrinter={Copy(%DefPrinter%,1,Pos(",",%DefPrinter%)-1)}
//Set the Printer
Run Program>rundll32 printui.dll,PrintUIEntry /y /n "PDFCreator"
//Print job is run
//Set the Printer back
Run Program>rundll32 printui.dll,PrintUIEntry /y /n "DefPrinter"
------------Working Script
//Get the default printer
RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Windows NT\CurrentVersion\Windows,Device,DefPrinter
Let>DefPrinter={Copy(%DefPrinter%,1,Pos(",",%DefPrinter%)-1)}
//Set the Printer
Run Program>rundll32 printui.dll,PrintUIEntry /y /n "PDFCreator"
//Print job is run
//Set the Printer back
Run Program>rundll32 printui.dll,PrintUIEntry /y /n "%DefPrinter%"
Help with Varexplicit - syntax error
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Regardless of what you have VAREXPLICIT set to it looks like you will ALWAYS need % symbols around DefPrinter on that last line because you want to embed its value in the line.
VAREXPLICIT=0 is the default anyway. So whether you have that line or omit it there won't be any difference in operation.
The correct syntax for what you want to do will always be:
Run Program>rundll32 printui.dll,PrintUIEntry /y /n "%DefPrinter%"
VAREXPLICIT=0 is the default anyway. So whether you have that line or omit it there won't be any difference in operation.
The correct syntax for what you want to do will always be:
Run Program>rundll32 printui.dll,PrintUIEntry /y /n "%DefPrinter%"
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?