Reputation: 2435
I'm trying to move away from Command Prompt, because it's a dead-end, over to PowerShell (ISE). I haven't figured out how to run command-line applications within the PowerShell (ISE) window. Everytime I use Start-Process a Command Prompt window appears (and disappears). I've seen some people suggest -Wait and -NoNewWindow but those haven't worked for me so far.
Start-Process MyApplication.exe
This starts Command Prompt, runs the application and disappears. PowerShell remains responsive.
Start-Process MyApplication.exe -Wait
This starts Command Prompt, runs the application and disappears. PowerShell doesn't get responsive until Command Prompt has exited.
Start-Process MyApplication.exe -Wait -NoNewWindow
This results in the following:
Start-Process : This command cannot be run due to the error: The system can not find the file specified.
Upvotes: 2
Views: 4443
Reputation: 25800
.
in PowerShell represents the current directory. This is to ensure that a user is not fooled into running a malicious executable at a folder specified by the $env:Path
environment variable.
From the about_Command_Precedence help content:
As a security feature, Windows PowerShell does not run executable (native) commands, including Windows PowerShell scripts, unless the command is located in a path that is listed in the Path environment variable (
$env:path
) or unless you specify the path to the script file.To run a script that is in the current directory, specify the full path, or type a dot (
.
) to represent the current directory.For example, to run the
FindDocs.ps1
file in the current directory, type:.\FindDocs.ps1
Upvotes: 1