Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening console applications in powershell

I'm currently developing a win32 console application, and wondering if there is any way to make visual studio open it in powershell instead of cmd.exe when I'm debugging it.

All I really want is a better shell, where I can copy/paste etc. without clicking.

Thanks

like image 910
Fredrik Avatar asked Jun 03 '10 16:06

Fredrik


People also ask

How do I run a console application?

Run the appPress Ctrl + F5 to run the program without debugging. A console window opens with the text "Hello World!" printed on the screen. Press any key to close the console window.

How do I open the PowerShell command prompt?

Run PowerShell as an Administrator from Command prompt Step 1: Open the Command Prompt, and type the PowerShell as a command, then press Enter key. Step 2: Now, the command prompt will turn to Windows PowerShell. Step 3: Type the command start-process PowerShell -verb runas and press "enter" key.

What is console application with example?

A console application is a computer program designed to be used via a text-only computer interface, such as a text terminal, the command-line interface of some operating systems (Unix, DOS, etc.) or the text-based interface included with most graphical user interface (GUI) operating systems, such as the Windows Console ...


2 Answers

I think you're mixing up the NT console subsystem (an app framework offerring common services) with cmd.exe (an application consuming those services.) When visuals studio runs a console application, it's not actually running CMD. CMD is a console application itself, no different than the app you are trying to debug, therefore running your application "in powershell" is equally as mistaken a concept.

If you mean trying to run it in PowerShell ISE, this is impossible. ISE is a Windows Application (NT GUI subsystem), which is an entirely different subsystem than that of the console.

-Oisin

like image 196
x0n Avatar answered Oct 07 '22 17:10

x0n


You can try this.

  1. Go to properties of your console project.
  2. In Debug tab select Start external program and enter path to powershell.exe (C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe)
  3. Enter ".\YourApp.exe" into Command line arguments

This starts your app in powershell. However it breaks a lot of things (like debugging, ...)

like image 34
Ondra Avatar answered Oct 07 '22 17:10

Ondra