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

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
BalcoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
eerwaltersConnect With a Mentor Commented:
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
 
Nagendra Pratap SinghCommented:
Is it a scheduled task?

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

You can run that command manually.
0
 
nettek0300Commented:
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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
BalcoAuthor Commented:
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
 
Nagendra Pratap SinghCommented:
Make it  a scheduled task with no further occurrences.

Ask the normal user to execute this task to copy / print the files.
0
 
BalcoAuthor Commented:
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
 
BalcoAuthor Commented:
Hi,

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

Cheers Mark
0
All Courses

From novice to tech pro — start learning today.