Print existing PDF file to a new PDF file using vbscript

Using this example to print a Windows printer test page to a PDF, is there a way to change this code to print an exiting PDF to a new PDF instead of printing the test page? I think it would be modifying the shell execute line in some fashion but I am not sure how. Anyone have a quick solution?

' PDFCreator COM Interface test for VBScript
' Part of the PDFCreator application
' License: GPL
' Homepage:
' Version: 1.1.0.0
' Created: June, 16. 2015
' Modified: May, 20. 2020
' Author: pdfforge GmbH
' Comments: This project demonstrates the use of the COM Interface of PDFCreator.
' This script converts a windows testpage to a .pdf file.
' Note: More usage examples then in the VBScript directory can be found in the JavaScript directory only.

Dim ShellObj, PDFCreatorQueue, scriptName, fullPath, printJob, objFSO, tmp
Const TemporaryFolder = 2

if (WScript.Version < 5.6) then
MsgBox "You need the Windows Scripting Host version 5.6 or greater!"
WScript.Quit
end if

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ShellObj = CreateObject("Shell.Application")
Set PDFCreatorQueue = CreateObject("PDFCreator.JobQueue")
fullPath = "C:\Convert\TestPage.pdf"

MsgBox "Initializing PDFCreator queue..."
PDFCreatorQueue.Initialize

MsgBox "Printing a windows testpage"
ShellObj.ShellExecute "RUNDLL32.exe", "PRINTUI.DLL,PrintUIEntry /k /n ""PDFCreator""", "", "open", 1

MsgBox "Waiting for the job to arrive at the queue..."
if not PDFCreatorQueue.WaitForJob(10) then
MsgBox "The print job did not reach the queue within " & " 10 seconds"
else
MsgBox "Currently there are " & PDFCreatorQueue.Count & " job(s) in the queue"
MsgBox "Getting job instance"
Set printJob = PDFCreatorQueue.NextJob

printJob.SetProfileByGuid("DefaultGuid")

MsgBox "Converting under ""DefaultGuid"" conversion profile"
printJob.ConvertTo(fullPath)

if (not printJob.IsFinished or not printJob.IsSuccessful) then
	MsgBox "Could not convert the file: " & fullPath
else
   MsgBox "File created: " & fullPath
MsgBox "Job finished successfully"
end if

end if

MsgBox "Releasing the object"
PDFCreatorQueue.ReleaseCom

Make a copy of the following sample script file and put it out of "C:\Program Files" so you can modify it without any harm:

"C:\Program Files\PDFCreator\Com Scripts\VBScript\TestPage2PDF.vbs"

This script creates a pdf, named TestPage_2Pdf.pdf and located in the %TEMP% folder, containing the Windows printer test page.

To print an existing PDF instead of the Windows printer test page, modify the script this way:

replace these two lines at line 29 and 30:
MsgBox "Printing a windows testpage"
ShellObj.ShellExecute "RUNDLL32.exe", "PRINTUI.DLL,PrintUIEntry /k /n ""PDFCreator""", "", "open", 1

with the following three lines:
MsgBox "Printing my pdf file"
ShellObj.ShellExecute "RUNDLL32.exe", "PRINTUI.DLL,PrintUIEntry /y /n ""PDFCreator""", "", "open", 1
ShellObj.ShellExecute "C:\Users\Wes\Desktop\My.pdf", "", "", "print", 0

  • the first ShellExecute set PDFCreator as the default printer

  • the second ShellExecute use the default program to open pdf files to send your file to the default printer
    Make sure that your can manage this request: Adobe Acrobat Reader is working well.