 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
jdolson
Joined: 05 Oct 2010 Posts: 8 Country: United States |
|
Unable to Set Default Printer |
|
We're running on Windows 7.
When the FilePrint command is executed an "Error opening print job" occurs.
If, in Control Panel, I manually set the default printer and I do not try to change the default printer through the PrinterSetDefault command, then I am able to print OK.
If, in the 24x7 script, I try to set the default printer, then trying to execute the FilePrint command gives an "Error opening print job".
The relevent section of code is shown below.
Any suggestions? Thanks!
Jim
IfThen ( ZWALK, IS_ZFM)
// Change default printer to ZFM printer
//PrinterSetDefault "\\ZMBSAT01P\ZMB21,winspool,Ne13:"
PrinterSetDefault "\\ZMBSAT01P\ZMB21"
Goto PRINT_FILE
IS_ZFM:
// Change default printer to ZFM printer
//PrinterSetDefault "\\ZMBSAT01P\ZMB24,winspool,Ne13:"
PrinterSetDefault "\\ZMBSAT01P\ZMB24"
Goto PRINT_FILE:
PRINT_FILE:
// Print the file contents
FilePrint local_file_name
|
|
Thu Oct 07, 2010 5:25 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7951
|
|
|
|
You need to escape all backslah symbols within literal values. Backslash \ symbols in JAL have special meaning. However, even if you change
 |
 |
IfThen ( ZWALK, IS_ZFM)
// Change default printer to ZFM printer
//PrinterSetDefault "\\\\ZMBSAT01P\\ZMB21,winspool,Ne13:"
PrinterSetDefault "\\\\ZMBSAT01P\\ZMB21"
Goto PRINT_FILE
IS_ZFM:
// Change default printer to ZFM printer
//PrinterSetDefault "\\\\ZMBSAT01P\\ZMB24,winspool,Ne13:"
PrinterSetDefault "\\\\ZMBSAT01P\\ZMB24"
Goto PRINT_FILE:
PRINT_FILE:
// Print the file contents
FilePrint local_file_name |
I'm not sure this method will work on Vista 7 and 2008. Here is what you can do to set the printer from a job, if the above fails. Note that the second example relies on printer names as they appear in the Printers list, not their network path. Windows will resolve the path automatically. Please set the correct printer names in the following script if you go with that approach
 |
 |
IfThen ( ZWALK, IS_ZFM)
// Change default printer to ZFM printer
VBSCriptExecute "Set WSHNetwork = CreateObject(\"WScript.Network\") \r\n WSHNetwork.SetDefaultPrinter \"ZFM - HP Color LaserJet 4500\" "
Goto PRINT_FILE
IS_ZFM:
// Change default printer to ZFM printer
VBSCriptExecute "Set WSHNetwork = CreateObject(\"WScript.Network\") \r\n WSHNetwork.SetDefaultPrinter \"ZMB - HP LaserJet CP2025\" "
PRINT_FILE:
// Print the file contents
FilePrint local_file_name |
|
|
Thu Oct 07, 2010 10:19 pm |
|
 |
jdolson
Joined: 05 Oct 2010 Posts: 8 Country: United States |
|
|
|
Hi SysOp.
The first method did not work. The second method results in the following error:
Job eCW Order Insurance Info execution error. Exit code: -1. An error occurred while executing a script: Line 64: Processing Error #23 Unable to execute script. Procedure "Main" not found.
Line 64 is:
VBScriptExecute "Set WSHNetwork = CreateObject(\"WScript.Network\") \r\n WSHNetwork.SetDefaultPrinter \"ZMB24 on ZMBSAT01P\" "
"ZMB24 on ZMBSAT01P" is the text desciption of the printer as it appears in the printer list in notepad, wordpad, etc.
Any suggestions?
Thanks,
Jim
|
|
Fri Oct 08, 2010 10:58 am |
|
 |
jdolson
Joined: 05 Oct 2010 Posts: 8 Country: United States |
|
|
|
Executing just the following line:
VBScriptExecute "Set WSHNetwok = WScript.CreateObject(\"WScript.Network\")"
Results in the same error:
Job eCW Order Insurance Info execution error. Exit code: -1. An error occurred while executing a script: Line 64: Processing Error #23 Unable to execute script. Procedure "Main" not found.
Any suggestions?
Thanks,
Jim
|
|
Fri Oct 08, 2010 12:30 pm |
|
 |
jdolson
Joined: 05 Oct 2010 Posts: 8 Country: United States |
|
|
|
OK, I'm no longer getting the error. I stuck a "sub main()" and "end sub" at the begging of the script and it now runs.
I'm getting an error indicating that "there is no printer call ZMB blah blah".
So at this point I think it's up to me to fix.
Thanks for your previous hlep.
Jim
|
|
Fri Oct 08, 2010 1:04 pm |
|
 |
jdolson
Joined: 05 Oct 2010 Posts: 8 Country: United States |
|
|
|
Here is the solution, in case anyone else has similar problems:
Dim vb, string
// Change default printer to ZWALK printer
ConcatEx "sub main() \r\n Set WSHNetwork = CreateObject(\"WScript.Network\")","\r\n","WSHNetwork.SetDefaultPrinter \"\\\\ZMBSAT01P\\ZMB24\" end sub",vb
VBScriptExecute (vb)
I had to add the "sub main()" and "end sub" to your example in order to make it work. Also, the printer name had to be the network path, not the printer name as it appears in the printer list.
Thanks again for your help.
Jim
|
|
Fri Oct 08, 2010 2:11 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7951
|
|
|
|
Thank you for posting the complete solution. It will surely help other people to resolve similar issues
|
|
Sat Oct 09, 2010 1:03 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|