【发布时间】:2021-11-22 22:19:45
【问题描述】:
如果变量 !batDir! 包含空格,我无法使以下批处理代码工作,例如W:\scripts windows\:
if /I "!i!" GTR "1" (
Powershell "!batDir!ript.ps1 !test! '!testWithSpaces!' "
goto :scriptEnd
)
W:\scripts : The term 'W:\scripts' is not recognized as the name of a cmdlet, function, script file, or operable
program.
【问题讨论】:
-
您是否尝试过
'!batDir!ript.ps1',即文件路径周围的单引号,例如'!testWithSpaces!'? -
然后我得到一个错误
Unexpected token '-filter' in expression or statement.变量!test!是-过滤器。 -
我认为这意味着路径已经合格。我建议先
echo表达式,然后再将其传递给 Powershell 进行调试。 -
Powershell "'W:\scrips windows\ript.ps1' -filter 'unity*' " -
请参阅this 从 CMD 运行 PS。
标签: powershell batch-file script