我有一个PowerShell脚本,当exe的路径中没有空格但不能使用空格时,该脚本可以工作。我该如何解决?
main.js
答案 0 :(得分:1)
使用&
呼叫运算符:
& 'C:\Program Files\a folder with many spaces in the title\bin\cwebp.exe' $img.FullName '-o' $outputName
或在变量中包含可执行路径:
$dir = "path/to/directory"
$images = Get-ChildItem $dir
$exe = "C:\Program Files\a folder with many spaces in the title\bin\cwebp.exe"
foreach ($img in $images) {
$outputName = Join-Path $img.DirectoryName ($img.BaseName + ".webp")
& $exe $img.FullName '-o' $outputName
}