This post is explaining the solution for the same observation but the resolution into this post is provide through a VBScript file rather than a batch file.
Problem with batch file:
Using batch file when printing process is completed for a PDF file then there is a adobe reader editor which was used during the printing process, remains open while it should be closed to get the right impression from end users/clients.
Resolution: To achieve the right scenario, I suggest to use the VBScript file rather than a batch file because customization and code writing is lot more easier than the command line.
VBScritp sample code:
'Assignments on global variables
strPrinterName = "HP LaserJet 3055 PCL6 Class Driver"
strPrinterDriver = "HP LaserJet 3055 PCL6 Class Driver"
strPrinterPort = "IP_172.16.16.103"
strAcroRead = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
'Get the file object
Set filesys = CreateObject("Scripting.FileSystemObject")
If Not filesys.FileExists(strPDFFolder & "\" & strPDFFile) Then
'Get an object of WScript
Set oShell = CreateObject("WScript.Shell")
'Integration of folder, files and printer detail
oShell.Run Chr(34) & strAcroRead & Chr(34) & " /t " _
& Chr(34) & strPDFFolder & "\" & strPDFFile & Chr(34) & " " _
& Chr(34) & strPrinterName & Chr(34) & " " & Chr(34) & strPrinterDriver & Chr(34) & " " & Chr(34) & strPrinterPort & Chr(34)
'Printing of the file will be completed at this point
'After allowing few seconds for spooling print job
'Delete the file from particular folder
'Check if file is existing
If filesys.FileExists(strPDFFolder & "\" & strPDFFile) Then
'Delete the file
filesys.DeleteFile strPDFFolder & "\" & strPDFFile
'May be there is an open application of adobe reader
'Check if there is an open instance of adobe reader then it should be closed
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'AcroRd32.exe'")
For Each objProcess in colProcessList
1. The above requirement has been analyzed on 32 bit Microsoft windows operating system.
2. There is only one pdf file, above methodology will not be supporting in case of multiple pdf files.
Mandatory items: There are following items must be available into the respective computer system.
1. Adobe reader must be installed to read the PDF file.
2. Printer must be configured into the source laptop to capture the print command.
1. Adobe reader exe location (Example- C:\Program Files (x86)\Adobe\Reader 11.0\Reader>AcroRd32.exe )
2. Subscribed SSRS pdf report location which is required to print on scheduled basis.
3. Printer name, Printer driver, Printer Port
1. Get the deployed SSRS report into PDF format using report subscription functionality
2. Print the same SSRS pdf report using command line utility which is a batch file
3. Schedule the batch file execution using Windows Task Scheduler or SQL Job Agent.
1. Open Task Scheduler by clicking the Start button, clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Task Scheduler.if you're prompted for an administrator password or confirmation, type the password or provide confirmation.
2. Click the Action menu, and then click Create Basic Task.