If I compile this c# code to an EXE file and run in a Windows command shell it runs fine: outputting the prompt, waiting on the same line for some user input followed by enter, echoing that input. Running in a PowerShell v3 shell it also runs fine. If, however, I run this same EXE file in PowerShell ISE V3, it never emits output from Write
and it hangs on the ReadLine
. (As an aside, it will emit output from Write
if it is later followed by a WriteLine
.)
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Console.Write("invisible prompt: ");
var s = System.Console.ReadLine();
System.Console.WriteLine("echo " + s);
}
}
}
Is this an ISE bug or is there some property to adjust to make it work...?
The reason PowerShell open on Startup is likely because you mistakenly added Windows PowerShell shortcut to the Start-up folder. What is this? If you also look at the Start-up tab of Task Manager, Windows PowerShell will be listed and status displayed as Enabled.
Open a PowerShell console session, type exit , and press the Enter key. The PowerShell console will immediately close. This keyword can also exit a script rather than the console session.
CTRL + C can be used when the context is unambiguous (when there is no text selected). CTRL + TAB Note: Tab to next script works only when you have a single Windows PowerShell tab open, or when you have more than one Windows PowerShell tab open, but the focus is in the Script Pane.
The Windows PowerShell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In the ISE, you can run commands and write, test, and debug scripts in a single Windows-based graphic user interface.
The ISE has no support for the console
class.
- No support for the [Console] class, try [console]::BackgroundColor = 'white'.
- In general, scripts should use the host API's (write-host, instead of the [Console] class, so that they work in both the console, ISE, Remoting and other shells.
Reference: http://blogs.msdn.com/b/powershell/archive/2009/04/17/differences-between-the-ise-and-powershell-console.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With