this is my first question on stackoverflow, so please be easy on me.
Problem: The call to an external EXE file from a Powershell Script should look like this.
C:\temp\someEXE.exe "batch" "B:\some path with spaces\file name with spaces.jpg" "" "C:\some other path"
My $Arguments Variable in the ps1-script looks like this.
$Arguments = '"batch"', "$Originalpath", '""', "$Outpath\$Outfile"
Start-Process -Wait -FilePath "C:\Temp\SomeExe.exe" -ArgumentList "$Arguments"
Argument 1 "batch" and 3, the empty "" works fine with the '""' (single - double - double - single).
But when i use the '"$Variable"' (single-double double-single) it is not interpreted according to the Quoting Rules (https://learn.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.1)
So my question is: How do i get from $Originalpath to "B:\some path with spaces\file name with spaces.jpg" incl. the ""
Thank you in advance
UPDATE: When i add a line to write the Parameters to a logfile, this line gives me what i need.
Write-output '"batch"',`"$Original`",'""',`"$AIAusgabepfad\$Originaldatei$Originaltyp`" | Out-file C:\Temp\Startup.log -append
But when i try to my $Arguments in the same way, the scriptwindow pops up and disapears in the same second.