Nimesha Rathnayake
Nimesha Rathnayake

Reputation: 43

Get windows username using typescript or javascript

In my angular 4 application I want to get windows username. Is it possible with typescript or java-script ? I am using the Chrome browser.

Upvotes: 0

Views: 5211

Answers (2)

lwallent
lwallent

Reputation: 242

Have you considered creating your application in Electron?

Electron is an open source library developed by GitHub for building cross-platform desktop applications with HTML, CSS, and JavaScript. Electron accomplishes this by combining Chromium and Node.js into a single runtime and apps can be packaged for Mac, Windows, and Linux.

Electron does not have the same security restrictions and you can still use Angular 4

If you choose to use Electron you can get userinfo through node.js os module:

The os.userInfo() method returns information about the currently effective user

Upvotes: 0

Rohit Tirmanwar
Rohit Tirmanwar

Reputation: 159

For security measures, I don't think it's possible to get the windows OS user information from browser using javascript/typescript.

Upvotes: 5

Related Questions