Sign in to follow this  
Followers 0

Name issues.

13 posts in this topic

Posted

I'm troubled by a little issue regarding user name.

This gives me Mola, which is my username.

MsgBox("","","User: " & @UserName & @CRLF & "Computer: " & @ComputerName)

But in the image below, the user's name is "Windows7".

On my pc it shows "Lastname, Firstname" (With my name ofcouce).

And i was just wondering if there was a way to get that name from somewhere?

So my script could say "Welcome, Firstname" instead of "Welcome, user"

post-65009-0-89648500-1336516978_thumb.p

Share this post


Link to post
Share on other sites



Posted

What does this return >> _WhoAmI

Share this post


Link to post
Share on other sites

Posted

Or what does this report?

; Generated by AutoIt Scriptomatic May 09, 2012

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

$Output=""
$Output &= "Computer: " & $strComputer  & @CRLF
$Output &= "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= "AccountType: " & $objItem.AccountType & @CRLF
      $Output &= "Caption: " & $objItem.Caption & @CRLF
      $Output &= "Description: " & $objItem.Description & @CRLF
      $Output &= "Disabled: " & $objItem.Disabled & @CRLF
      $Output &= "Domain: " & $objItem.Domain & @CRLF
      $Output &= "FullName: " & $objItem.FullName & @CRLF
      $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output &= "LocalAccount: " & $objItem.LocalAccount & @CRLF
      $Output &= "Lockout: " & $objItem.Lockout & @CRLF
      $Output &= "Name: " & $objItem.Name & @CRLF
      $Output &= "PasswordChangeable: " & $objItem.PasswordChangeable & @CRLF
      $Output &= "PasswordExpires: " & $objItem.PasswordExpires & @CRLF
      $Output &= "PasswordRequired: " & $objItem.PasswordRequired & @CRLF
      $Output &= "SID: " & $objItem.SID & @CRLF
      $Output &= "SIDType: " & $objItem.SIDType & @CRLF
      $Output &= "Status: " & $objItem.Status & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_UserAccount" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Share this post


Link to post
Share on other sites

Posted

What does this return >> _WhoAmI

Mola

Or what does this report?

; Generated by AutoIt Scriptomatic May 09, 2012

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

$Output=""
$Output &= "Computer: " & $strComputer  & @CRLF
$Output &= "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= "AccountType: " & $objItem.AccountType & @CRLF
      $Output &= "Caption: " & $objItem.Caption & @CRLF
      $Output &= "Description: " & $objItem.Description & @CRLF
      $Output &= "Disabled: " & $objItem.Disabled & @CRLF
      $Output &= "Domain: " & $objItem.Domain & @CRLF
      $Output &= "FullName: " & $objItem.FullName & @CRLF
      $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output &= "LocalAccount: " & $objItem.LocalAccount & @CRLF
      $Output &= "Lockout: " & $objItem.Lockout & @CRLF
      $Output &= "Name: " & $objItem.Name & @CRLF
      $Output &= "PasswordChangeable: " & $objItem.PasswordChangeable & @CRLF
      $Output &= "PasswordExpires: " & $objItem.PasswordExpires & @CRLF
      $Output &= "PasswordRequired: " & $objItem.PasswordRequired & @CRLF
      $Output &= "SID: " & $objItem.SID & @CRLF
      $Output &= "SIDType: " & $objItem.SIDType & @CRLF
      $Output &= "Status: " & $objItem.Status & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_UserAccount" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Computer: localhost
==========================================
AccountType: 512
Caption: MAN-MOLA15\Administrator
Description: Innebygd konto for administrasjon av datamaskinen/domenet
Disabled: False
Domain: MAN-MOLA15
FullName:
InstallDate: // ::
LocalAccount: True
Lockout: False
Name: Administrator
PasswordChangeable: True
PasswordExpires: False
PasswordRequired: True
SID: S-1-5-21-3427169424-2513921749-2469644734-500
SIDType: 1
Status: OK

---------------------------
WMI Output
---------------------------
AccountType: 512
Caption: MAN-MOLA15\Gjest
Description: Innebygd konto som gir gjester tilgang til datamaskinen/domenet
Disabled: True
Domain: MAN-MOLA15
FullName:
InstallDate: // ::
LocalAccount: True
Lockout: False
Name: Gjest
PasswordChangeable: False
PasswordExpires: False
PasswordRequired: False
SID: S-1-5-21-3427169424-2513921749-2469644734-501
SIDType: 1
Status: Degraded

---------------------------
OK   Avbryt  
---------------------------

Then if i spam click OK it goes through alot of users, most likely teachers, and shows most of the same.

After some clicks alot of them have their full name just like "Lastname, Firstname"

But the ones with Mola had either "Student" or "Guest" as name ;)

Share this post


Link to post
Share on other sites

Posted

So this isn't on your own system?

Share this post


Link to post
Share on other sites

Posted

So this isn't on your own system?

;)

Share this post


Link to post
Share on other sites

Posted

What's returned is determined by how your account is set up on the domain. If your user name is Mola, then they may have set your First Name/Last Name to Student in AD, if you're using AD.

Share this post


Link to post
Share on other sites

Posted (edited)

So this isn't on your own system?

Well, no. Im renting from the school so they can give us word and stuff so we don't have to buy it.

So... No, but i get it after school.

What's returned is determined by how your account is set up on the domain. If your user name is Mola, then they may have set your First Name/Last Name to Student in AD, if you're using AD.

Not sure what AD is reffering to...

Nvm ;)

I thought that my name has to be stored in some variable or file.

And maybe there is a function or script that can get that name :/

Edited by Maffe811

Share this post


Link to post
Share on other sites

Posted

Have you tried water's UDF?

Share this post


Link to post
Share on other sites

Posted

Have you tried water's UDF?

The AD UDF ? I took a look at it, but it said someplace that most of the functions use AD_Open or something like that.

But im not in school right now, im home. And it still sais my name in the menu.

Share this post


Link to post
Share on other sites

Posted

Yeh. Well I'm out of ideas for now. Sorry Maffe811.

Share this post


Link to post
Share on other sites

Posted

Well thanks anyways! ;)

Ill just have to search around to see if i can do something clever...

Share this post


Link to post
Share on other sites

Posted

What about this?

Func _GetDisplayName()
    Local $aResult = DllCall("secur32.dll", "BOOL", "GetUserNameExW", "int", 3, "wstr", "", "dword*", 256)
    If @error Or Not $aResult[0] Or Not $aResult[2] Then Return @UserName
    Return $aResult[2]
EndFunc

MsgBox(0, '', _GetDisplayName())

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  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.