[SERVER-9310] Shell doesn't work when started from a PowerShell ISE session Created: 10/Apr/13  Updated: 13/Jan/17  Resolved: 13/Jan/17

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Tom Robinson Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 2
Labels: WIndows, powershell, shell
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 8, Windows PowerShell ISE 3.0


Attachments: PNG File screenshot.png    
Operating System: Windows
Steps To Reproduce:

1. Open the PowerShell ISE
2. Execute mongo.exe at the PowerShell prompt
3. The following will be displayed:

MongoDB shell version: 2.4.1
connecting to: test

Participants:

 Description   

When starting the mongo.exe process from within a PowerShell ISE session, control is not returned to the user and the prompt doesn't appear.

The attached screenshot shows the expected behaviour (Command Prompt and standard PowerShell session) compared to a PowerShell ISE session.



 Comments   
Comment by Justin Cohler [ 13/Jan/17 ]

We currently only support cmd.exe and powershell.exe

Comment by Tom Robinson [ 11/Apr/13 ]

Since it sounds like this can't be fixed fully, an error message would be good - just to let the user know what is happening.

This blog post confirms the problem is in the PowerShell ISE:
http://blogs.msdn.com/b/powershell/archive/2009/02/04/console-application-non-support-in-the-ise.aspx

It's a shame because it's much simpler to select, copy and paste text inside the PowerShell ISE shell.

Comment by Tad Marshall [ 11/Apr/13 ]

When I break into the mongo.exe process in the debugger while it is hung in PowerShell ISE, it is in a call to ReadConsoleInputW(). Since there is no console to read from, this call never returns. To either make this work when run directly in PowerShell ISE or to detect this situation and exit with an error message, we'd need some additional code. This could be done, but perhaps it isn't as worthwhile as other things that we could work on since the workaround (run the shell in the environment that it was written for, i.e. the Windows console) is pretty easy.

Comment by Tad Marshall [ 11/Apr/13 ]

The 'start-process' command starts mongo.exe in its own Command Prompt window, so it works fine that way.

Comment by Adeyemi Adegbile [ 10/Apr/13 ]

To Start Mongo from the PowerShell ISE Session use the full path to the Mongo application,but make sure that you have a running instance of mongod or else the session will automatically close as shown below

start-process C:\mongodb2_4_1\mongodb-win32-i386-2.4.1\bin\mongod.exe

start-process C:\mongodb2_4_1\mongodb-win32-i386-2.4.1\bin\mongo.exe

Comment by Tad Marshall [ 10/Apr/13 ]

This is a family of Windows functions that let a program work directly with its "container".

For example:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681913(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684202(v=vs.85).aspx

These functions are used by the shell on Windows, and their absence is why you see nothing when running mongo.exe in the ISE.

Comment by Tom Robinson [ 10/Apr/13 ]

I'm not sure what you mean by "PowerShell ISE does not provide a Console windows or its own Console API"

Comment by Tad Marshall [ 10/Apr/13 ]

I'm not sure that this makes sense. The mongo.exe shell uses Windows Console APIs to get its input and produce its output, and the PowerShell ISE does not provide a Console windows or its own Console API, so this would be a rewrite of the I/O routines. The mongo.exe shell works fine in a regular PowerShell console window.

Generated at Thu Feb 08 03:20:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.