Windows PowerShell ISE doesn't promt for input - windows

I am using console as my tool for managing mercurial repositories. Wtih classic cmd or Console2 I type:
hg in
And console prompts something like:
D:\workspace\someproject>hg in
http authorization required
realm: Bitbucket.org HTTP
user: xorty
password:
And obviously, I type password.
But when I type "hg in" in powershell console, it doesn't prompt anything. It just keeps saying this:
Running script / selection. Press Ctrl + Break to stop
Can I make PowerShell ISE behave like classic console, or this isn't the way PowerShell is meant to work?

The PowerShell ISE indeed does not support console applications that require interactive input. The linked blog entry details options how to deal with that.
Since the PowerShell ISE is not a console, normal console applications cannot do everything they're used to, while of course PowerShell cmdlets can work just fine, since several things are dependent on the PowerShell host application (you get a graphical prompt with Read-Host, for example).
Console2 emulates a normal console by keeping the actual console around in a hidden window and polling it repeatedly for changes and, correspondingly, sending input to that window.

Powershell ISE ( integrated scripting environment ) is not the standard Powershell console. The ISE, like the name suggests, is a pretty basic GUI based script writing tool and doesn't support interactive console applications ( try just cmd on the ISE console and see the error message)
Open powershell.exe, and run the command that you want. It will behave pretty much like cmd. Or alternatively, press CTRL+SHIFT+P in the ISE and run the command there.

Related

How to clear line or password prompt in Windows PowerShell like CTRL+U in Linux?

When using Linux, you can use CTRL+U for clearing the current prompt. This is very useful, when entering a password and you need to clear the current (hidden) password, to write it again, for example because you made a typo.
However, this will not work out-of-the-box in Windows PowerShell, using Windows Terminal. When you press CTRL+U, you will see ^U instead of clearing the line. Of course, this will not work for password prompt also, like in C:\WINDOWS\System32\OpenSSH\ssh.exe.
Which process would responsible for this feature? Windows Terminal, PowerShell, PSReadLine? I guess, it's not ssh.exe.
Is there any known way to achieve this feature?

golang: optional console on windows

I am writing a service program which is expected to run in background. On Windows it will open a console window when run. I want it to go to background directly without that console window, so I used the -ldconf "-H=windowsgui" option, which worked as expected.
However, there is a catch. The program has a command line option -help, which output command line usage in the console. If I use -H=windowsgui, the help text is NOT printed even I start it in cmd.exe prompt.
It seems that the windowsgui option is not what I want. Is there anyway that the -help still works at commant line, and the console window will not persist if the program runs normally. I do not care if there is a console window pops up, provided that it disappears shortly without user intervention. i.e. I want a way on windows which is similar to the & operator on Linux.
P.S. if provided solution uses any other tools, I want that tool to be a Windows component, not any 3rd-party program. Thanks.

Alternative to cmd and powershell for stdout output only

My use case:
I kick-off a Python script from a button within Excel to do some data aggregation. The setup currently works nicely, but I would like:
Cmd to never accidentally pause - it's a known feature of the command prompt to pause on any text selection: Avoid pausing tasks when select something on PowerShell and Command Prompt
To let the cmd prompt look more like a pop-up
I have noticed NSIS installers outputs it's commands in a little logging box:
Question:
I would like to know if there are any programs out there that does most of what I want already. E.g. something like RunLikePopup.exe c:\path\to\script.bat, with output like:
Not sure what you are really after. I 'll give it a try.
In case you build an application as 'console'-only than that results in a 'command-line-interface [CLI]' Look-and-feel. Plane and simple. The output of a NSIS script (.nsi file) can not be paused as it is simply the output of the compiler executing the script code. 'Pausing' that would instantly mean pausing the compiler to do its work. I see no reason why you would want that.
Example Unix 'more' command (sending text oriented content to stdout. CLI...)
https://en.wikipedia.org/wiki/More_(command)
In case you need to 'catch' the output from the NSIS compiler here is what you need to do:
run NSIS from (Windows) CLI:
makensis [ option | script.nsi | - ] [...] > compiler_log.txt
What you appear to want is typically named 'output redirect'. (https://ss64.com/nt/syntax-redirection.html). In case you need to 'catch' the outpout from a NSIS script at compile time, please use NSIS ' CLI and redirect the (compilers) output to any text file (e.g. compiler_output.txt)
PS. In order to ensure receiving good quality answers, try to be as specific as you can in your questions.
I have written a Freeware editor ME "Martins Editor" where you can send text via inpipe:
[C:\]dir /s | me in
"in" always shows the first page (does not scroll), "ins" scrolls and "inp" scrolls page by page. In this context, "me in" is a substitute for "more".
Then you will see the output in the editor. ME is a simple editor with the focus on multiplatform text (different EOL encodings, codepages). It has additional Wordstar ("IDE classic") key setting and HTML/XML highlightning. It is available for Windows, OS/2, Linux and MacOS.
http://www.hypermake.com/english/betatest.html#hd117
The 2016 version is still current. In the next weeks, I publish a new version.
I am working on a cmd.exe window replacement (commandline frontend) "MeShell" based on ME with look-and-feel of a normal commandline window. Because on the lack of a modern comfortable commandline window on the old OS/2 platform which is still alive (http://www.arcanoae.com), I will publish an OS/2 version first. If this version works fine, I will publish a Windows version later. In the context of MeShell, I improve the inpipe functionality of ME which is still buggy and does not support colors in the 2016 version.

Windows Batch: Running a Ruby program opens a cmd window

I basically would like to execute a (Cygwin-) Ruby program by clicking on some icon on my desktop. My first attempt went like this:
Create a desktop link
As a link target, have something like
c:\cygwin64\bin\ruby /path/to/my/ruby/program
This works, but it also opens a window where Ruby "runs in", which is not what I want to have.
If it were ActiveState Perl, I would have a command "wperl", which executes Perl without creating a Window, but such an feature doesn't seem to exist for Ruby, at least not for the Cygwin distribution.
I tried to change the link to
cmd /MIN /C c:\cygwin64\bin\ruby /path/to/my/ruby/program
hoping, that this would run the window minimized, but same effect as before, so I think I need to program somehow a wrapper script which suppresses the creation of this window. Does anybody know how this can be done, preferably using the Windows Batch language or some clever commands in the Cygwin tool chain?

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
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
You can try this.
Go to properties of your console project.
In Debug tab select Start external program and enter path to powershell.exe (C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe)
Enter ".\YourApp.exe" into Command line arguments
This starts your app in powershell. However it breaks a lot of things (like debugging, ...)
In Visual Studio goto Tools > External Tools...
In this window you can change the Title to Powershell. Set the Powershell Startup to execute and the check the output window box and it will dump all the output that would typically goto cmd into Powershell.
This link will explain it a little bit more for you.

Resources