Batch file 使用set设置特殊字符似乎不起作用[Bat]

Batch file 使用set设置特殊字符似乎不起作用[Bat],batch-file,Batch File,我正在编写一个简单的批处理文件,用于根据请求输出JAR 所以当我写论点的时候,它一定看起来像 但是,我不想直接写入output%%~nj.txt,而是想使用一个变量,以便在需要时可以输出到文件中 我试过很多方法 但到目前为止没有运气 这是我的代码片段 ::per is a variable about setting input or not ::per gets changed to a string after being checked, to be used in java as an

我正在编写一个简单的批处理文件,用于根据请求输出JAR 所以当我写论点的时候,它一定看起来像

但是,我不想直接写入output%%~nj.txt,而是想使用一个变量,以便在需要时可以输出到文件中

我试过很多方法 但到目前为止没有运气

这是我的代码片段

::per is a variable about setting input or not
::per gets changed to a string after being checked, to be used in java as an arg.
::echo test works so I am sure that there are no errors on that section
IF [%per%]==[1] (set "per= < "input!pth!.txt" > "output%pth%.txt""&echo test)

::testing if per works as intended
::must show per: < "input!pth!.txt" > "output%pth%.txt"
Echo per: %per%

::per shows 1 instead of < "input!pth!.txt" > "output%pth%.txt"
::filename is the name of the jar with .jar
java -Xmx1024M -jar %filename%%per%

那么,我如何将每个变量设置为output%%~nj.txt?

您忘记了变量的延迟扩展。啊,我忘了在代码段中添加它,但我启用了延迟扩展。我想他的意思是,不要使用Echo per:%per%,而应该使用Echo per:!每测试它是否按预期工作。嗯,让我给它一个点击,它将在一秒钟内更新,因为我认为!每未声明为变量echo shouts!每不是%per%: