Jump to content
Sign in to follow this  
adrigalilea

Windows 8 retrieve username information.

Recommended Posts

adrigalilea

Hi, i want to retrieve the current user information like, Name, Full name, Description, and other data like the email, which is stored because windows 8 logs in with that information and appears in the users menu.

I have no idea, I've googled it and i don't know how to get this kind of information.

I'm working in windows 8 non domain host.

EDIT: I've found something: >LINK

But not full name or email, how can i have this information?

Edited by adrigalilea

Share this post


Link to post
Share on other sites
DW1

You could grab that data with WMI

#include <array.au3>

Static $wbemFlagReturnImmediately = 0x10
Static $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Local $aReturn[100][3]
Local $i = 0

If IsObj($colItems) Then
    For $objItem In $colItems
        $aReturn[$i][0] = $objItem.Name
        $aReturn[$i][1] = $objItem.Description
        $aReturn[$i][2] = $objItem.FullName
        $i += 1
    Next
    ReDim $aReturn[$i][3]
Else
    MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_UserAccount")
EndIf

_ArrayDisplay($aReturn, 'Users', '', 0, Default, 'Name|Description|FullName')

Share this post


Link to post
Share on other sites
adrigalilea

 

You could grab that data with WMI

#include <array.au3>

Static $wbemFlagReturnImmediately = 0x10
Static $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Local $aReturn[100][3]
Local $i = 0

If IsObj($colItems) Then
    For $objItem In $colItems
        $aReturn[$i][0] = $objItem.Name
        $aReturn[$i][1] = $objItem.Description
        $aReturn[$i][2] = $objItem.FullName
        $i += 1
    Next
    ReDim $aReturn[$i][3]
Else
    MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_UserAccount")
EndIf

_ArrayDisplay($aReturn, 'Users', '', 0, Default, 'Name|Description|FullName')

Cool, works perfect, but is there anyway to get the email too?

Share this post


Link to post
Share on other sites
DW1

Is an email going to be part of a local user profile in a non AD environment?

I don't have access to my Win8 machine at the moment.  Is this new to Win8?

Share this post


Link to post
Share on other sites
adrigalilea

I think is new in windows 8 as far as you create the user as microsoft suggest with your outlook mail. I think is part of the local user profile and internally instead of the username that appears its using the mail instead as i saw several times like in the registry, for example in the default logon user the reference to the user is the mail and not the name of the user. Example:

  • open cmd -> whoami -> NameOfTheComputerUsername
  • open cmd -> echo %username% -> Username
  • open regedit -> HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon -> DefaultUserName -> MicrosoftAccountUserMail@outlook.com

Share this post


Link to post
Share on other sites
DW1

I can't test alternatives since I'm not in front of a Win8 machine at the moment, but if you're saying you can grab it via registry, why not just script that?

Share this post


Link to post
Share on other sites
adrigalilea

I can't test alternatives since I'm not in front of a Win8 machine at the moment, but if you're saying you can grab it via registry, why not just script that?

Because it wont work in every machine, i mean what if the machine have multiple users? the defaultUserName wont be the desired one in every scenario, so im looking for the correct way to do it and i cant find one.

Thank you for your time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×