Printing via Command Line works on Server, but not from a Workstation
zaq1028
Member Posts: 19
I am working on a report that prints through to a printer by exporting a text file and sending it to a printer through command line. It works when I run it from the server, but not from a workstation. The printer is shared and connected to the workstation. My code:
Any ideas?
OutputFile.TEXTMODE(TRUE); OutputFile.CREATE(FilePath + 'templabel.txt') FOR i := 1 TO 100 DO BEGIN OutputFile.WRITE(PrintString[i]); END; OutputFile.CLOSE; Command := 'C:\Windows\System32\cmd.exe /c type ' + FilePath + 'templabel.txt > "' + PrinterPath + '"'; ShellInt := 1; RunModally := FALSE ; CREATE(WSHShell,FALSE,ISSERVICETIER); WSHShell.Run(Command,ShellInt,RunModally); CLEAR(WSHShell); ERASE(FilePath + 'templabel.txt');
Any ideas?
0
Comments
-
May be the file is created on Server and you are trying to print file from Local path.
Did you check that?0 -
How does this run from the server? Are you not trying to call automation here - and you can;t run that on the server... Your CREATE should fail on a server. Do you mean you can run the command manually on the server directly from the command prompt? What is the declaration of your WSHShell variable? Also try running your command manually on the workstation - does that work? Could be a simple permission issue on the workstation...0
-
Do you mean it works on server when you are running the Windows Client directly on the server?0
-
Also your code looks like you are creating a file on the server... I think this code will only work when you run it on the server from the Window Client. What you should do if you don't want to change it too much is download the file from the server to a tempfile on your client and then run the command. Then delete the tempfile client side and the one you had server side. Check FileManagement codeunit for how to do this.0
-
That won't help until the code is fixed...0
-
This is ran as a page action from the Item card.
The create does not fail, the text file is created and written to.
I can run it manually from the Command Prompot and through the NAV Report.
WSHShell is declared as 'Windows Script Host Object Model'.WshShell.
It works when I run it using the NAV Client on the Windows Server.0 -
They found a report that worked with their Label Printer, and I recreated that to get around the issue. Thanks for your assistance all the same!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
