无法使用空格解析路径到powershell

问题描述 投票:0回答:1

我试图从autoit通过powershell将文件搜索发送到已创建的行。

这是我试图使用的完整运行命令(https://www.autoitscript.com/autoit3/docs/functions/Run.htm):

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-ChildItem -File D:\__Temp\123\2 - Copy -Recurse -Filter *.dcm | ForEach-Object {  '<image>' + $_.FullName + '</image>' } | Out-File -FilePath D:\Temp\scan.txt -Append -Encoding UTF8

我已经尝试在路径上使用几个“或”,但似乎没有任何工作,shell只是在没有文件写入的情况下立即退出。

这是我尝试过的:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-ChildItem -File 'D:\__Temp\123\2 - Copy' -Recurse -Filter *.dcm | ForEach-Object {  '<image>' + $_.FullName + '</image>' } | Out-File -FilePath D:\Temp\scan.txt -Append -Encoding UTF8

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-ChildItem -File "D:\__Temp\123\2 - Copy" -Recurse -Filter *.dcm | ForEach-Object {  '<image>' + $_.FullName + '</image>' } | Out-File -FilePath D:\Temp\scan.txt -Append -Encoding UTF8
windows powershell cmd command autoit
1个回答
1
投票

感谢mklement0的提示,这是可行的解决方案:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Get-ChildItem -File 'D:\__Temp\123\2 - Kopie  dads ds a' -Recurse -Filter *.dcm | ForEach-Object {  '<image>' + $_.FullName + '</image>' } | Out-File -FilePath C:\Users\LUKAS~1.WIL\AppData\Local\Temp\DB_Tool_jDicomCC\scan.txt -Append -Encoding UTF8"

也就是说,整个-Command参数包含在"..."中,带有空格的嵌入路径包含在'...'中。

© www.soinside.com 2019 - 2024. All rights reserved.