In a PowerShell window I am executing:
Start-Process XXXXX.exe -ArgumentList "some valid arguments" -wait
-redirectStandardOutput "D:\\test1.txt"
And getting:
Start-Process : This command cannot be executed due to the error: The system cannot find the file specified.
At line:1 char:14
+ Start-Process <<<< XXXXX.exe -ArgumentList "some valid arguments here" -redirectStandardOutput "D:\\test1.txt"
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
I have checked that the start-process works as expectedif I omit the -redirectStandardOutput argument (it does).
The test1.txt is a NEW file, not trying to append.
The suprising thing is that the test1.txt file on D:\ is created when I run the line, it just remains empty.
Has anyone any idea what is happening here? Thanks.
EDIT
I discovered that if I run:
Start-Process XXXXX.exe -ArgumentList "some valid arguments" -wait
-redirectStandardOutput "D:\\test1.txt"
it fails (as originally posted) If I run:
Start-Process XXXXX.exe -ArgumentList "some valid arguments" -wait
it works fine but doesnt save the console output to a file and if I run
Start-Process .\XXXXX.exe -ArgumentList "some valid arguments" -wait
-redirectStandardOutput "D:\\test1.txt"
It works pretty much as expected. So why do I need to specify the path when I am using the redirection but when I am not it runs happily?
EDIT To recapitulate the problem; there appears to be some inconsistancy regarding the requirement that scripts/exes in the current directory require a ./ prefix to be allowed to run. When I am not redirecting the output the ./ is NOT required. Anyone know if this is expected behavior?