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

时间:2020-07-21 21:00:52

标签: java windows powershell batch-file

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

当我将其粘贴到命令行上时,该命令可以正确运行

java "-Dcloudcard.api.accessToken=s0olREDACTEDREDACTEDREDACTEDREDACTED" "-Ddownlo
ader.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 m
ore 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' is not recognize
d as an internal or external command,
operable program or batch file.

谢谢!

1 个答案:

答案 0 :(得分: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中更具可读性