問題描述
如何使用 NodeJS 獲取/查找計算機所有者當前(登錄時)使用的用戶名?
How would I get/find the username that the computer owner is using currently (while logged in), using NodeJS?
我已經搜索了一些,但沒有找到任何東西.
I have searched around a bit, but haven't found anything.
推薦答案
我不知道為什么,但是有人添加了一個答案,然后很快就刪除了它......我很快就抓住了它,在檢查之后,這是完成我之前要求的最短和最有效的方法:
I am not sure why, but someone added an answer and then deleted it quickly after... I was fast enough to catch it though, and after checking, it is the shortest and most effective way of doing what I asked before:
require("os").userInfo().username
唯一的問題是,在 Windows 10 中,它返回已使用的所有者帳戶的名字(只是提醒).其他一切都很好!
The only problem is, in Windows 10, it returns the first name of the owner account that has been used (just a heads up). Everything else works completely fine!
這篇關于如何在 NodeJS 中獲取操作系統用戶名?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!