Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-05-12
7
Medium Priority
?
1,247 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 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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
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 2000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

824 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