-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Add "(Administrator)" suffix to window title when running as administrator in Windows #19707
Comments
I was hoping to work on this issue and I figured out how to implement it, but it seems that translation strings need to be modified, which are seemingly done by a third party. The suffix would need to be added within this block, and using some method to determine if the application is being run with Admin privileges. I suppose this would need to be implemented by the VS Code team? |
@arkon I think the biggest issue is that I am not sure how to find out that VS Code runs as "Admin". If someone has an idea, I am happy to add it 👍 |
@bpasero I linked to a StackOverflow thread about that previously that should work: http://stackoverflow.com/a/37670360 |
Ugly. Imho this should go into either a native node module or better, into Electron itself ( |
Maybe we should request it upstream for Electron to expose functions to check if we're running as administrator (Windows) or root (UNIX)? |
We can, but only with a PR 👍 |
@bpasero Seems like they might favour users using a separate node module for checking for elevated privileges rather than having it implemented as part of Electron (electron/electron#8980 (comment)). |
Since they suggested is-elevated, I suppose we could use that here? |
Last time I checked these modules seem to spawn a process on Windows at least? That is not a solution I would want. A module should use some native code to find out if the user is Admin or not. |
Hmm, perhaps you could voice your opinion on that electron thread then? |
@arkon sorry I missed your reference to that PR, it looks very cool. Any reason you could not make that a native module? VS Code would use it right away. |
@arkon exactly! since you already did the hard part of writing the C code, putting this to a native module is not a lot of work imho. See for example this module that we are using which does that: https://github.com/the-ress/node-windows-foreground-love |
@bpasero Ah, I see! I'll try my hand at making a native module then. |
Awesome 👍 |
I've published native-is-elevated to NPM. |
Thanks, I will look into this for April! |
Awesome, nice work @arkon! |
I played around with the library and noticed that on Windows calling into the module can take 32ms (on my fast macbook pro, running in a VM). Given our performance work we are doing I am feeling not so easy adding this to the critical startup path (the title is on it). I also noticed that the library is not needed on mac or linux where finding out if the user is root or not is I think what we can do is the following:
If someone wants to step in, my work is in 3ac3f1e |
Would it help if native-is-elevated's |
@arkon good point, maybe not a promise but a typical function callback, as with other functions in node that are long running (e.g. Though could you actually implement that because it seems your call in C land is sync? |
@bpasero It ought to be possible. I found this example of using promises, and it seems like Nan could be useful for implementing callbacks. I'll give it a shot. EDIT: oh wait, I see what you mean by the call being synchronous. I suppose there'd be no way to make it asynchronous unless it somehow did it in a different thread, but the whole point of this was to avoid spawning something extra... 🤔 |
Yeah thats what I think too. That is why my initial reaction was to call this method only after a delay. I can look into it, actually requiring the module is not what takes time, it is calling into that method so we can probably keep that module on all platforms. |
I'm noticing some fallout that may be related to this issue. |
Yeah maybe it is too aggressive to show this on Windows where it is more likely that you run as admin. I can take it out again. |
Verification: |
@bpasero Any reason we are going with the square brackets [] instead of the normal ones () ? |
@ramya-rao-a no, I just picked that style up from the other decorations we had ("Unsupported" and "Extension Development Host"). |
got it |
Steps to Reproduce:
Since running as administrator works pretty well now, the only thing that's missing is an indication that the window has been run as administrator. Visual Studio (and other apps) use the title bar to indicate this:
The text was updated successfully, but these errors were encountered: