问题
I run the following command in a Windows batch file:
start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file 1.pdf" /A "page=4&zoom=55.5" "G:\my pdfs\file 2.pdf"
The works perfectly fine and opens both PDF files using their respective parameters. However, to make the process cleaner, I would like to start using variables in place of the PDF files (and even the PDF viewer executable). However, when I use variables, only the first PDF file opens:
set PDF1="G:\my pdfs\file 1.pdf"
set PDF2="G:\my pdfs\file 2.pdf"
start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" %PDF1% /A "page=4&zoom=55.5" %PDF2%
I should mention that I don't have this issue if I remove the /A
command and the subsequent parameters for each file.
回答1:
Wrong quotation in set
commands. Use set "variable=value"
syntax as follows:
set "PDF1=G:\my pdfs\file 1.pdf"
set "PDF2=G:\my pdfs\file 2.pdf"
start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "%PDF1%" /A "page=4&zoom=55.5" "%PDF2%"
来源:https://stackoverflow.com/questions/28775849/expanding-variables-in-a-windows-batch-file