在Windows批处理文件扩展变量 [英] Expanding variables in a Windows batch file
问题描述
我在Windows批处理文件运行以下命令:
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"
作品完美的罚款,并打开使用其各自的参数都PDF文件。然而,为了使这个过程更清洁,我想开始的地方PDF文件(甚至PDF阅读器可执行文件)的使用变量。然而,当我使用变量,只有第一个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%
我要指出,我没有这个问题,如果我删除 / A
命令和每个文件的后续参数。
I should mention that I don't have this issue if I remove the /A
command and the subsequent parameters for each file.
推荐答案
在错误引用设置
命令。如下使用设置变量=值
语法:
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%"
这篇关于在Windows批处理文件扩展变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!