Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Hide console when running outside a terminal #327

Open
eebssk1 opened this issue Jan 12, 2024 · 7 comments
Open

Feature Request: Hide console when running outside a terminal #327

eebssk1 opened this issue Jan 12, 2024 · 7 comments

Comments

@eebssk1
Copy link

eebssk1 commented Jan 12, 2024

Description

I'm using gsudo prepended on a shortcut to start a GUI program as admin.(gsudo cache auto spawned via taskscheduler)
Everytime I open the shotcut it flashes a cmd windows quickly and then start the target application.
This is a bit annoying to me.

Proposed technical details

I found a workaround, by prepending "conhost.exe --headless" which precreate a invisible console that gsudo will take over.
It's better if there is something like gsudow which supports this natively.

@eebssk1
Copy link
Author

eebssk1 commented Jan 13, 2024

Also There's a weired API behavior of OBS started by gsudo(normal or cache).
The monitor capturing api failed with 0x8007006(HANDLE_INVLAID) error although it has admin rights.
And I found the fix is set "Run as admin for this user" on the obs64.exe and it works normally after started by gsudo. Pretty weired hmmm.

@gerardog
Copy link
Owner

Hi @eebssk1,

Windows spawns the console before actually starting gsudo, hence gsudo.exe can't avoid the console from flashing, besides what is already doing. BTW super nice hack with the conhost.exe --headless prefix!

Another workaround is to set the shortcut to show minimized, which reduces the flashing to just a minimum on to the taskbar:
image

The idea of having a different gsudow.exe compiled as a windows app just to solve this particular annoyance, IMO is just going to bring more confusion that benefits. How would a console-less gsudo show errors, outputs, etc? And the problem it solves can be avoided so easily.... So, I am sorry, but I am going to close this one as By Design.

Regarding the OBS issue, that's an interesting one that can get more attention. We can repurpose this issue in that direction if you want instead of creating another one. Do you have a stacktrace or additional debug info, logs, repro steps on obs, etc? Thank you.

@eebssk1
Copy link
Author

eebssk1 commented Jan 14, 2024

Hi @gerardog . Then let's focusing on the OBS one and repurpose the issue.

OBS log is here though there's no much useful infomation > https://catbin.sh/b/c17c3e15

It's rather easy to reproduce. You just start obs with gsudo and then add monitor capture source, then it fails.

There's a pretty weired workaround. You tick the "Run as admin" for this user compatibility flag of obs64.exe and then start with gsudo and it the works without problem.

PS:Looks like only monitor capture api has such problem so maybe some windows internal related.

@eebssk1
Copy link
Author

eebssk1 commented Jan 14, 2024

Hi @gerardog . Then let's focusing on the OBS one and repurpose the issue.

OBS log is here though there's no much useful infomation > https://catbin.sh/b/c17c3e15

It's rather easy to reproduce. You just start obs with gsudo and then add monitor capture source, then it fails.

There's a pretty weired workaround. You tick the "Run as admin" for this user compatibility flag of obs64.exe and then start with gsudo and it the works without problem.

PS:Looks like only monitor capture api has such problem so maybe some windows internal related.

Just found another weired point. The way in workaround always start OBS in minimized.

@eebssk1
Copy link
Author

eebssk1 commented Feb 9, 2024

Hi @gerardog . Then let's focusing on the OBS one and repurpose the issue.

OBS log is here though there's no much useful infomation > https://catbin.sh/b/c17c3e15

It's rather easy to reproduce. You just start obs with gsudo and then add monitor capture source, then it fails.

There's a pretty weired workaround. You tick the "Run as admin" for this user compatibility flag of obs64.exe and then start with gsudo and it the works without problem.

PS:Looks like only monitor capture api has such problem so maybe some windows internal related.

Hmm I reinstalled windows in this lunar new year and then the issue is gone...
All possible changes I do is I only prepended 'start ""' before the command..

@Kamilkampfwagen-II
Copy link

run-hidden could be used for this.
The final command line: run-hidden.exe gsudo.exe mspaint

@eebssk1
Copy link
Author

eebssk1 commented Mar 29, 2024

@gerardog Hi. Thanks for the new release.
Also I found the myth here.
As long as you start obs detached from gsudo,then there will be no problems.
like this C:\Windows\System32\conhost.exe --headless gsudo start "" D:\Portable\OBS\bin\64bit\obs64.exe
cmd's start cmdlet without any arguments start process in detached mode ,where process itself becomes the group leader,not a subprocess of gsudo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants