0

I am trying to fire a filesearch from Autoit via powershell to an already created line.

This is the full run command ( https://www.autoitscript.com/autoit3/docs/functions/Run.htm ) I am trying to go with :

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

I already tried to use several " or ' around the path but nothing seemed to work and the shell just exits instantly without the filewrite.

Here's what I've tried:

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
1
  • 1
    Related. Commented Mar 11, 2019 at 16:55

1 Answer 1

1

Thanks to the tip from mklement0 this is the working solution:

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"

That is, the entire -Command argument is enclosed in "...", and the embedded path with spaces is enclosed in '...'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.