Solved

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

Posted on 2013-05-12
7
1,118 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
7 Comments
 
LVL 23

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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 23

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

770 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