Node.Js - Get windows username

Benjamin

I am trying to get the windows username of the machine that is running my node.jS app (the app is always running on a Windows machine).

How can I get the current windows username using Node.Js?

I am trying to find something similar to WindowsIdentity.GetCurrent().Name in C# for node.js, or whoamI command in CMD.

Karthik M

Since Node v6 (2016-04), you can just use os.userInfo :

var os = require('os');
os.userInfo().username

To get the current logged-in username:

var path = require('path');
var userName = process.env['USERPROFILE'].split(path.sep)[2];
var loginId = path.join("domainName",userName);
console.log(loginId);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

get node.js for windows without msi

From Dev

Proper way to get the windows UserName

From Dev

How to get Windows start username?

From Dev

Authentication with username & password with node js, AngularJs and JWT

From Dev

How to get remote username on windows machine

From Dev

How to get Windows version using Node.js?

From Java

Cannot get the id of a username Discord JS

From Dev

Get User Username - discord.js

From Dev

how to get soundcloud username with passport.js

From Dev

Get UserName in a Windows 10 C# UWP Universal Windows app

From Dev

Cannot `/GET` Node JS

From Dev

Node.js Passport Display username after successful login

From Dev

Node.js Passport strategy login with either Email or Username

From Dev

Authenticate on Azure AD with username and password in a Node.js web app

From Dev

Verifying if an input is a username or email with node.js and mysql

From Dev

Sendgrid node.js error 535 bad username/password

From Dev

Node.js Passport Display username after successful login

From Dev

How to get current windows username and disable the credentials prompting?

From Dev

How to get windows login username in asp.net with single sign on

From Dev

How to get username/SID from session id in Windows?

From Dev

How to get windows login username in asp.net with single sign on

From Dev

How to get the windows username associated with a process (in Framework 4.0)

From Dev

Get Windows username containing non-english chars in c#

From Dev

How to get a username in Active Directory and use it in Windows Services?

From Dev

node js process name on windows

From Dev

Complication with Node.JS on Windows

From Dev

Uninstall Node js Windows 10

From Dev

Complication with Node.JS on Windows

From Dev

Get Windows user id in my node js so I can authenticate against ldap

Related Related

  1. 1

    get node.js for windows without msi

  2. 2

    Proper way to get the windows UserName

  3. 3

    How to get Windows start username?

  4. 4

    Authentication with username & password with node js, AngularJs and JWT

  5. 5

    How to get remote username on windows machine

  6. 6

    How to get Windows version using Node.js?

  7. 7

    Cannot get the id of a username Discord JS

  8. 8

    Get User Username - discord.js

  9. 9

    how to get soundcloud username with passport.js

  10. 10

    Get UserName in a Windows 10 C# UWP Universal Windows app

  11. 11

    Cannot `/GET` Node JS

  12. 12

    Node.js Passport Display username after successful login

  13. 13

    Node.js Passport strategy login with either Email or Username

  14. 14

    Authenticate on Azure AD with username and password in a Node.js web app

  15. 15

    Verifying if an input is a username or email with node.js and mysql

  16. 16

    Sendgrid node.js error 535 bad username/password

  17. 17

    Node.js Passport Display username after successful login

  18. 18

    How to get current windows username and disable the credentials prompting?

  19. 19

    How to get windows login username in asp.net with single sign on

  20. 20

    How to get username/SID from session id in Windows?

  21. 21

    How to get windows login username in asp.net with single sign on

  22. 22

    How to get the windows username associated with a process (in Framework 4.0)

  23. 23

    Get Windows username containing non-english chars in c#

  24. 24

    How to get a username in Active Directory and use it in Windows Services?

  25. 25

    node js process name on windows

  26. 26

    Complication with Node.JS on Windows

  27. 27

    Uninstall Node js Windows 10

  28. 28

    Complication with Node.JS on Windows

  29. 29

    Get Windows user id in my node js so I can authenticate against ldap

HotTag

Archive