2

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.

5
  • Try with the full path to the .exe. Or if it is at the current path use .\MyApplication.exe Commented Jul 1, 2014 at 4:20
  • I added the .\ to the beginning of the file name and it worked, but why? Commented Jul 1, 2014 at 4:34
  • I added the response as an answer. Please mark it if you think that answers this comment and your question. Commented Jul 1, 2014 at 5:17
  • It does but what about PowerShell ISE? Commented Jul 1, 2014 at 5:31
  • @HelloWorld, you might also like to check out ConEmu. PowerShell runs nicely in that. Commented Jul 1, 2014 at 6:30

1 Answer 1

1

. 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
Sign up to request clarification or add additional context in comments.

4 Comments

This works in PowerShell but PowerShell ISE starts Command Prompt which then runs the application.
ISE is not a console host per se. It is a WPF app emulating console experience. So, the native commands behave differently there. But, the concept of .\ does not change between console and ISE.
Yes, the .\ works but the application doesn't get run inside ISE. The thing is that I'm working with applications that rely on Unicode and the Win32 console (Command Prompt/Windows PowerShell) doesn't handle it but I've been told that ISE does support Unicode and therefore I need to run the application inside ISE.
Yes, that is correct. ISE supports unicode but like I said it is not a console host but just a WPF application.

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.