Solved

Use a batch file to transfer and print a file on a print server

Posted on 2013-05-12
7
1,173 Views
Last Modified: 2013-05-13
Hi,

I am trying to get the attached batch file to send and print a file to our print server.

The batch file works on our old print server which is a windows 2003 server and a domian controller.

When I go to run it on our new print server which is Windows Server 2008 R2 and also our Active directorey server I get Access is denied as per attached jpeg. If I run the job as a Domain Admin it works fine. I have given a test account full print, manage printer and manage documents and still no luck.

i have also disabled the firewall on the print server and terminal server and still get the same access denied message.

I know it is a permissions issue but am not sure where to go and look now.

Thanks Mark
Access-Denied.JPG
PRN-batch.txt
0
Comment
Question by:Balco
[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
7 Comments
 
LVL 24

Expert Comment

by:Nagendra Pratap Singh
ID: 39160435
Is it a scheduled task?

You can make it a scheduled task and feed domain creds.

You can run that command manually.
0
 
LVL 6

Expert Comment

by:nettek0300
ID: 39160436
My guess is that the test account does not have access to read the file from the Windows 2008 R2 server.  I would verify the permissions on the temp directory to make sure the test account has access to the file.  Are you able to sign on to the server using the test account and read the file?
0
 

Author Comment

by:Balco
ID: 39160451
Hi,

This is not a scheduled task.

Yes the test account can access the file on the terminal server as it can copy it to another folder. What it cant do is copy the file to the print server queue.

Cheers
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 24

Expert Comment

by:Nagendra Pratap Singh
ID: 39160479
Make it  a scheduled task with no further occurrences.

Ask the normal user to execute this task to copy / print the files.
0
 

Author Comment

by:Balco
ID: 39160480
All I wont the user to do is click on a file when they receive it and it prints. the print files have a .pclz extension which I have setup to be associate with the batch file when clicked on.

The print file is never the same, so I dont see how a scheduled task can work.
0
 
LVL 7

Accepted Solution

by:
eerwalters earned 500 total points
ID: 39162245
If you want to use a batch file, the smoothest way is to remove Windows permissions and standard Windows shared print queues from the equation.

There will be 5 basic steps to resolve the issue
    1- Setup the printer on the Windows 2008 server
    2- Install LPD print service on the Windows 2008 server hosting the desired printers
    3- Install LPR port monitor on the workstation(s) from which you want to send the file
    4- Modify your bat file to set the desired host and printer name
    5- Test the bat file

Step 1 - Setup the printer on the Windows 2008 server
    a- I am assuming that this step is already completed on the server and the printer is printing from the server

Step 2 - Enable LPD Service on the Windows 2008 server hosting the desired printer(s)
  If Server Manager loads after logging in, jump to item b, otherwise...
    a- GoTo Start and type servermanager.msc in the search box and hit Enter
    b- Click on Add Role Services on the right
      under Roles | Print and Document Services | Roles Services
    c- Enable the LPD Service
    d- Click on Next
    e- Click Install
    f- Click Close
    g- GoTo Start
    h- Type services.msc in the search box and hit Enter
    i- Start the LPD Service if it is not started

Step 3 - Enable LPR on the Windows 7 workstation(s) that will need to send the file
    a- GoTo Start and type appwiz.cpl in the search box and hit Enter
    b- Click on Turn Windows features on and off in the left pane
    c- Click the + sign next to Print and Document Services
    d- Enable the feature for LPR Port Monitor
    e- Click OK
    f- You may be prompted to Restart

Step 4 - Modify your batch file to set the variables for the desired printer
    Notes:    
      a- The printer_host is the DNS name or TCP/IP address of the Windows 2008 print server hosting the desired printer
      b- The printer_name is the name of the printer on the Windows 2008 print server
      c- You should try the LPR command manually first to insure success before putting it into the batch file
******************************************************
rem -----------------------------------------------------------
rem -- When the printer is on an LPD Host
rem -----------------------------------------------------------
set PRINTER_HOST=LPDserver
set PRINTER_NAME=myUSBprinter


rem -----------------------------------------------------------
rem -- LPR the source file to the hosted printer
rem -----------------------------------------------------------

type %1 > %TMP%\aqhc.tmp
LPR -S %Printer_Host% -P %Printer_Name% c:\\BSM\Temp\aqhc.tmp
pause
del %TMP%\aqhc.tmp
del %1
********************************************************

Step 5 - Test the batch file

Notes:
  If the device that needs to send the file is not a Windows 7 PC (Step 3), let me know the OS version and I can provide specific instructions on how to enable LPR for that OS.
0
 

Author Closing Comment

by:Balco
ID: 39163668
Hi,

Thanks for the solution, it was very easy to follow.

Cheers Mark
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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