SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Unable to Set Default Printer

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Unable to Set Default Printer
Author Message
jdolson



Joined: 05 Oct 2010
Posts: 8
Country: United States

Post Unable to Set Default Printer Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7952

Post Reply with quote
You need to escape all backslah symbols within literal values. Backslash \ symbols in JAL have special meaning. However, even if you change

Code:
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

Code:
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 View user's profile Send private message
jdolson



Joined: 05 Oct 2010
Posts: 8
Country: United States

Post Reply with quote
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 View user's profile Send private message
jdolson



Joined: 05 Oct 2010
Posts: 8
Country: United States

Post Reply with quote
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 View user's profile Send private message
jdolson



Joined: 05 Oct 2010
Posts: 8
Country: United States

Post Reply with quote
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 View user's profile Send private message
jdolson



Joined: 05 Oct 2010
Posts: 8
Country: United States

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7952

Post Reply with quote
Thank you for posting the complete solution. It will surely help other people to resolve similar issues
Sat Oct 09, 2010 1:03 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.