命令在命令行上运行,但在批处理文件中不运行。

huangapple go评论113阅读模式
英文:

Command Runs on Command Line But Not in Batch File

问题

抱歉,如果这是一个简单的问题,但我感到困惑。请帮助!

当我将此命令粘贴到命令行时,它可以正常运行:

java "-Dcloudcard.api.accessToken=s0olREDACTEDREDACTEDREDACTEDREDACTED" "-Ddownloader.fetchStatuses=READY_FOR_DOWNLOAD,APPROVED" "-Ddownloader.photoDirectories=C:\UCI_ID\ID_Photos\student\Pictures" -jar cloudcard-photo-downloader.jar

然而,当我将其保存到批处理文件中时,它不能正确运行。它似乎在等号(=)处拆分命令。以下是我得到的输出...

C:\UCI_ID\cloudcard-photo-downloader>Run2

C:\UCI_ID\cloudcard-photo-downloader>java "-Dcloudcard.api.accessToken=
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available

... {java usage output removed for brevity} ...

    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

C:\UCI_ID\cloudcard-photo-downloader>s0olREDACTEDREDACTEDREDACTEDREDACTED" "-Ddownlo
ader.fetchStatuses=READY_FOR_DOWNLOAD,APPROVED" "-Ddownloader.photoDirectories=C
:\UCI_ID\ID_Photos\student\Pictures" -jar cloudcard-photo-downloader.jar
's0olp4k40nbooqjfvn3mkvbe4ftceocd" "-Ddownloader.fetchStatuses' 不被视为内部或外部命令、可操作的程序或批处理文件。

提前感谢!

英文:

I'm sorry if this is a simple question, but I'm befuddled. Please, help!

This command runs correctly when I paste it on the command line

java &quot;-Dcloudcard.api.accessToken=s0olREDACTEDREDACTEDREDACTEDREDACTED&quot; &quot;-Ddownlo
ader.fetchStatuses=READY_FOR_DOWNLOAD,APPROVED&quot; &quot;-Ddownloader.photoDirectories=C
:\UCI_ID\ID_Photos\student\Pictures&quot; -jar cloudcard-photo-downloader.jar

However, when I save in into a batch file, it does not run correctly. It seems to be splitting the command at the = sign. Below is the output I get...

C:\UCI_ID\cloudcard-photo-downloader&gt;Run2

C:\UCI_ID\cloudcard-photo-downloader&gt;java &quot;-Dcloudcard.api.accessToken=
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available

... {java usage output removed for brevity} ...

    -javaagent:&lt;jarpath&gt;[=&lt;options&gt;]
                  load Java programming language agent, see java.lang.instrument

    -splash:&lt;imagepath&gt;
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.

C:\UCI_ID\cloudcard-photo-downloader&gt;s0olREDACTEDREDACTEDREDACTEDREDACTED&quot; &quot;-Ddownlo
ader.fetchStatuses=READY_FOR_DOWNLOAD,APPROVED&quot; &quot;-Ddownloader.photoDirectories=C
:\UCI_ID\ID_Photos\student\Pictures&quot; -jar cloudcard-photo-downloader.jar
&#39;s0olp4k40nbooqjfvn3mkvbe4ftceocd&quot; &quot;-Ddownloader.fetchStatuses&#39; is not recognize
d as an internal or external command,
operable program or batch file.

Thanks in advance!

答案1

得分: 1

将以下内容原样复制到您的batch-file中:

java -Dcloudcard.api.accessToken="s0olREDACTEDREDACTEDREDACTEDREDACTED" ^
-Ddownloader.fetchStatuses="READY_FOR_DOWNLOAD,APPROVED" ^
-Ddownloader.photoDirectories="C:\UCI_ID\ID_Photos\student\Pictures" ^
-jar cloudcard-photo-downloader.jar

当然,也可以将其放在一行上,但这会去掉插入符号^,但在这里和您的batch-file中,这样做会使其更易读。

英文:

Copy this as is into your batch-file:

java -Dcloudcard.api.accessToken=&quot;s0olREDACTEDREDACTEDREDACTEDREDACTED&quot; ^
-Ddownloader.fetchStatuses=&quot;READY_FOR_DOWNLOAD,APPROVED&quot; ^
-Ddownloader.photoDirectories=&quot;C:\UCI_ID\ID_Photos\student\Pictures&quot; ^
-jar cloudcard-photo-downloader.jar

It can also be single line, obviously then excluding the carets ^, but this makes it a little more readable here and in your batch-file

huangapple
  • 本文由 发表于 2020年7月22日 05:00:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/63023038.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定