Raj
Raj

Reputation: 1551

How to correctly quote a command with parameters in a Windows batch file

I am attempting to open multiple PDF files in multiple tabs in multiple windows using PDF X-Change Viewer, which has command line options. All PDF files listed in the same line open within the same window.

To allow the script to proceed without waiting for the windows created on each line to close, I am attempting to use start. However, start requires some awkward quoting it seems, and this has created issues when trying to pass in parameters.


The following script does work:

start "" "C:\PDF Viewer\PDFXCview.exe" "G:\my pdfs\file1.pdf" "G:\my pdfs\file2.pdf"
start "" "C:\PDF Viewer\PDFXCview.exe" "G:\my pdfs\file3.pdf" "G:\my pdfs\file4.pdf"

The following script does not work

(it only opens the first file in each line, although the page and zoom are obeyed for that file):

start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file1.pdf" "G:\my pdfs\file2.pdf"
start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file3.pdf" "G:\my pdfs\file4.pdf"

If I don't use start, simply running: "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file1.pdf" "G:\my pdfs\file2.pdf" works fine with the parameters.

Upvotes: 0

Views: 255

Answers (1)

pathe3
pathe3

Reputation: 348

When using start, specify the /A command and parameters for each file to be opened:

start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\mypdfs\file1.pdf" /A "page=4&zoom=55.5" "G:\my pdfs\file2.pdf"

Upvotes: 1

Related Questions