sublime_terminal icon indicating copy to clipboard operation
sublime_terminal copied to clipboard

Hide Command prompt on Windows

Open shirhatti opened this issue 10 years ago • 16 comments

Open Terminal Here briefly shows a cmd.exe window before launching powershell.exe

This can be easily hidden by passing a startupinfo argument to subprocess.Popen() Would like me to submit a pull request?

if os.name == 'win':
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    subprocess.Popen(args, cwd=cwd, startupinfo=startupinfo)
else:
    subprocess.Popen(args, cwd=cwd)

shirhatti avatar Aug 06 '14 06:08 shirhatti

Bump!

shirhatti avatar Aug 15 '14 18:08 shirhatti

up

AuthorProxy avatar Nov 18 '14 16:11 AuthorProxy

How would that fix work if someone doesn't have powershell installed and they are launching cmd.exe?

twolfson avatar Jun 13 '15 12:06 twolfson

What versions of Windows are you running? I would just want to make sure this change doesn't break on different versions of Windows.

wbond avatar Jun 14 '15 00:06 wbond

It has been 1 month since we replied on this issue but with no updates from the commenters. Closing this issue for now.

twolfson avatar Jul 13 '15 02:07 twolfson

@twolfson This issue should be open. Although I use git bash without any bug but for those who use default powershell then this issue is occurring. @wbond On windows 8 this occurs for me :)

shivapoudel avatar Jul 14 '15 14:07 shivapoudel

Alright, reopening issue

twolfson avatar Jul 14 '15 17:07 twolfson

@shivapoudel Can you also provide the version of Sublime Text you are using so we can reproduce more easily?

twolfson avatar Jul 15 '15 05:07 twolfson

I have successfully reproduced on an ievm for Windows 7 and Sublime Text 3. However, I am not too sure of the best approach. The one mentioned earlier seems like it will be problematic for non-bat invocations (e.g. cmd.exe, Cmder.exe) as it would hit the initial window.

@shivapoudel Do you have any solutions and would you be interested in opening a PR?

twolfson avatar Jul 15 '15 05:07 twolfson

@twolfson Using Sublime Text 3 build 3083. Found temporary solution but not sure this will help all =/

{
    "terminal": "powershell",
    "parameters": []
}

shivapoudel avatar Jul 15 '15 08:07 shivapoudel

Interesting. @wbond Can you provide insight into why we have a .bat and don't invoke powershell.exe?

twolfson avatar Jul 15 '15 16:07 twolfson

Well, the subprocess package in Python uses cmd.exe to start the subprocess. If you launch powershell.exe through the subprocess package, powershell inherits the window dimensions of cmd.exe and the color scheme also. The batch script launches powershell with a ps1 script to reset the dimensions to something reasonable and the default color scheme.

In order to fix this issue "properly," and get rid of the batch script, I believe the solution would be to use the Win32 API to launch the powershell process. I have never done such a thing before, but it would need to be done through ctypes. My guess is a call to something like https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx.

wbond avatar Jul 15 '15 17:07 wbond

@twolfson If you can then please help this bug fix ASAP. Sorry my bad luck but I haven't written python code till the date so I am unable to submit the PR.

shivapoudel avatar Jul 15 '15 18:07 shivapoudel

I don't think this is a critical bug; it doesn't break anyone's UI. It causes a minor inconvenience which resolves itself.

I am inexperienced with Windows programming as well. I am going to leave this PR as "enhancement"/"help wanted" for anyone who wants to repair this and has knowledge of Windows (or has the time to learn).

twolfson avatar Jul 15 '15 18:07 twolfson

@taragurung Do you have any solutions and would you be interested in opening a PR?

shivapoudel avatar Jul 17 '15 09:07 shivapoudel

let me check

On Fri, Jul 17, 2015 at 2:52 PM, Shiva Poudel [email protected] wrote:

@taragurung https://github.com/taragurung Do you have any solutions and would you be interested in opening a PR?

— Reply to this email directly or view it on GitHub https://github.com/wbond/sublime_terminal/issues/65#issuecomment-122224980 .

taragurung avatar Jul 18 '15 09:07 taragurung